117692024-11-09 20:08:56balintSzámjegycserecpp17Wrong answer 0/10023ms664 KiB
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int n;
    scanf("%d", &n);
    getchar();
    bool arr[5] = {false};
    char last = '\0';
    char c = '\0';
    char buff;
    for (int _ = 0; _ < n; _++)
    {
        for (int i = 0; i < 5; i++)
        {
            arr[i] = false;
        }
        while (true)
        {
            buff = getchar();
            // 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\n");
        }
        else
        {
            if (c == '0')
            {
                if (last == '0' || last == '5')
                {
                    printf("0\n");
                }
                else
                {
                    printf("1\n");
                }
            }
            else if (c == '5')
            {
                if (last == '2' || last == '7')
                {
                    printf("0\n");
                }
                else
                {
                    printf("1\n");
                }
            }
            else
            {
                printf("2\n");
            }
        }
    }

    return 0;
}
// 00
// 25
// 50
// 75
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
subtask20/21
2Wrong answer3ms320 KiB
subtask30/23
3Wrong answer8ms568 KiB
4Wrong answer8ms568 KiB
5Wrong answer8ms572 KiB
6Wrong answer8ms644 KiB
7Wrong answer8ms652 KiB
8Wrong answer8ms596 KiB
9Wrong answer8ms568 KiB
10Wrong answer8ms568 KiB
11Wrong answer8ms568 KiB
12Wrong answer8ms568 KiB
13Wrong answer8ms612 KiB
14Wrong answer8ms588 KiB
15Wrong answer8ms584 KiB
16Wrong answer9ms596 KiB
17Wrong answer8ms516 KiB
18Wrong answer9ms560 KiB
19Wrong answer9ms556 KiB
20Wrong answer9ms600 KiB
21Wrong answer9ms400 KiB
22Wrong answer10ms520 KiB
23Wrong answer9ms568 KiB
subtask40/41
24Accepted1ms320 KiB
25Accepted1ms508 KiB
26Accepted1ms320 KiB
27Accepted1ms320 KiB
28Accepted1ms320 KiB
29Accepted1ms320 KiB
30Accepted1ms320 KiB
31Accepted1ms388 KiB
32Accepted1ms356 KiB
33Wrong answer1ms320 KiB
34Accepted1ms320 KiB
35Accepted1ms320 KiB
36Accepted1ms332 KiB
37Accepted1ms320 KiB
38Accepted1ms320 KiB
39Accepted1ms320 KiB
40Accepted1ms320 KiB
41Accepted1ms320 KiB
42Accepted1ms320 KiB
43Accepted1ms512 KiB
44Accepted1ms508 KiB
45Accepted1ms332 KiB
46Wrong answer1ms512 KiB
47Wrong answer1ms320 KiB
subtask50/15
48Wrong answer16ms320 KiB
49Wrong answer16ms392 KiB
50Wrong answer23ms536 KiB
51Wrong answer16ms388 KiB
52Wrong answer17ms320 KiB
53Accepted6ms320 KiB
54Accepted6ms320 KiB
55Accepted6ms424 KiB
56Accepted9ms568 KiB
57Accepted8ms388 KiB
58Accepted4ms392 KiB
59Accepted4ms320 KiB
60Accepted4ms388 KiB
61Accepted4ms320 KiB
62Accepted4ms320 KiB
63Accepted6ms388 KiB
64Accepted9ms604 KiB
65Accepted9ms664 KiB
66Accepted9ms624 KiB