117672024-11-09 19:36:31balintSzámjegycserecpp17Runtime error 0/1002ms756 KiB
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int n;
    scanf("%d", &n);
    scanf("%c");
    bool arr[5];
    char last;
    char c;
    char buff;
    for (int _ = 0; _ < n; _++)
    {
        while (true)
        {
            scanf("%c", &buff);
            if (buff == '\n')
            {
                break;
            }
            last = c;
            c = buff;

            switch (c)
            {
            case '0':
                if (arr[0])
                {
                    arr[1] = true;
                }
                else
                {
                    arr[0] = true;
                }
                break;
            case '2':
                arr[2] = true;
                break;
            case '5':
                arr[3] = true;
                break;
            case '7':
                arr[4] = true;
                break;
            }
        }
        if (!((arr[0] && arr[1]) || (arr[2] && arr[3]) || (arr[3] && arr[0]) || (arr[4] && arr[3])))
        {
            printf("-1");
        }
        else
        {
            if (c == '0')
            {
                if (last == '0' || last == '5')
                {
                    printf("0");
                }
                else
                {
                    printf("1");
                }
            }
            else if (c == '5')
            {
                if (last == '2' || last == '7')
                {
                    printf("0");
                }
                else
                {
                    printf("1");
                }
            }
            else
            {
                printf("2");
            }
        }
    }

    return 0;
}
// 00
// 25
// 50
// 75
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error1ms320 KiB
subtask20/21
2Runtime error1ms320 KiB
subtask30/23
3Runtime error1ms320 KiB
4Runtime error1ms320 KiB
5Runtime error1ms756 KiB
6Runtime error1ms756 KiB
7Runtime error1ms508 KiB
8Runtime error1ms512 KiB
9Runtime error1ms320 KiB
10Runtime error1ms508 KiB
11Runtime error1ms320 KiB
12Runtime error1ms320 KiB
13Runtime error1ms320 KiB
14Runtime error1ms508 KiB
15Runtime error1ms320 KiB
16Runtime error1ms320 KiB
17Runtime error1ms320 KiB
18Runtime error1ms320 KiB
19Runtime error1ms500 KiB
20Runtime error1ms320 KiB
21Runtime error1ms320 KiB
22Runtime error1ms320 KiB
23Runtime error1ms500 KiB
subtask40/41
24Runtime error1ms320 KiB
25Runtime error1ms320 KiB
26Runtime error1ms320 KiB
27Runtime error1ms320 KiB
28Runtime error2ms388 KiB
29Runtime error1ms376 KiB
30Runtime error1ms320 KiB
31Runtime error1ms320 KiB
32Runtime error1ms320 KiB
33Runtime error1ms576 KiB
34Runtime error1ms320 KiB
35Runtime error1ms320 KiB
36Runtime error1ms320 KiB
37Runtime error1ms320 KiB
38Runtime error1ms508 KiB
39Runtime error1ms320 KiB
40Runtime error1ms336 KiB
41Runtime error1ms320 KiB
42Runtime error1ms320 KiB
43Runtime error1ms320 KiB
44Runtime error1ms320 KiB
45Runtime error1ms388 KiB
46Runtime error1ms320 KiB
47Runtime error1ms320 KiB
subtask50/15
48Runtime error2ms320 KiB
49Runtime error2ms320 KiB
50Runtime error1ms568 KiB
51Runtime error1ms320 KiB
52Runtime error1ms568 KiB
53Runtime error1ms320 KiB
54Runtime error1ms320 KiB
55Runtime error1ms320 KiB
56Runtime error1ms320 KiB
57Runtime error1ms320 KiB
58Runtime error1ms320 KiB
59Runtime error1ms320 KiB
60Runtime error1ms500 KiB
61Runtime error1ms320 KiB
62Runtime error1ms320 KiB
63Runtime error1ms320 KiB
64Runtime error1ms320 KiB
65Runtime error1ms320 KiB
66Runtime error1ms320 KiB