117682024-11-09 19:38:35balintSzámjegycserecpp17Runtime error 0/1002ms756 KiB
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int n;
    scanf("%d", &n);
    scanf("%c");
    bool arr[5] = {false};
    char last = '\0';
    char c = '\0';
    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 error1ms324 KiB
6Runtime error1ms556 KiB
7Runtime error2ms320 KiB
8Runtime error1ms320 KiB
9Runtime error1ms320 KiB
10Runtime error1ms320 KiB
11Runtime error1ms320 KiB
12Runtime error1ms320 KiB
13Runtime error1ms320 KiB
14Runtime error1ms320 KiB
15Runtime error1ms512 KiB
16Runtime error1ms520 KiB
17Runtime error1ms320 KiB
18Runtime error1ms320 KiB
19Runtime error1ms320 KiB
20Runtime error1ms320 KiB
21Runtime error1ms568 KiB
22Runtime error1ms320 KiB
23Runtime error1ms320 KiB
subtask40/41
24Runtime error1ms320 KiB
25Runtime error1ms320 KiB
26Runtime error1ms508 KiB
27Runtime error1ms320 KiB
28Runtime error1ms496 KiB
29Runtime error1ms512 KiB
30Runtime error1ms320 KiB
31Runtime error1ms320 KiB
32Runtime error1ms320 KiB
33Runtime error1ms320 KiB
34Runtime error1ms320 KiB
35Runtime error1ms548 KiB
36Runtime error1ms320 KiB
37Runtime error1ms320 KiB
38Runtime error1ms320 KiB
39Runtime error1ms320 KiB
40Runtime error1ms500 KiB
41Runtime error1ms432 KiB
42Runtime error1ms496 KiB
43Runtime error1ms320 KiB
44Runtime error1ms512 KiB
45Runtime error1ms320 KiB
46Runtime error1ms320 KiB
47Runtime error1ms320 KiB
subtask50/15
48Runtime error1ms508 KiB
49Runtime error1ms756 KiB
50Runtime error1ms320 KiB
51Runtime error1ms320 KiB
52Runtime error2ms568 KiB
53Runtime error1ms508 KiB
54Runtime error1ms320 KiB
55Runtime error1ms320 KiB
56Runtime error1ms320 KiB
57Runtime error2ms388 KiB
58Runtime error1ms320 KiB
59Runtime error1ms320 KiB
60Runtime error1ms320 KiB
61Runtime error1ms320 KiB
62Runtime error1ms320 KiB
63Runtime error1ms384 KiB
64Runtime error1ms320 KiB
65Runtime error1ms320 KiB
66Runtime error1ms320 KiB