122032024-12-09 12:06:59CsongiSzámjegycserecpp17Wrong answer 0/100172ms784 KiB
#include <bits/stdc++.h>
using namespace std;

bool ketnulla(const string& str)
{
    int szam = 0;
    for (char c : str)
    {
        if (c==0)
        {
            szam++;
        }
        if (szam == 2)
        {
            return true;
        }
    }
    return false;
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    for (int i = 0; i < n; i++)
    {
        string be; cin >> be;
        //string be = to_string(be);
        if ((be[be.size()-1]=='0' && be[be.size()-2]=='0') || (be[be.size()-1]=='5' && be[be.size()-2]=='2') || (be[be.size()-1]=='5' && be[be.size()-2]=='7') || (be[be.size()-1]=='0' && be[be.size()-2]=='5'))
        {
            cout << "0" << endl;
        }
        else if (be[be.size()-1]=='0')
        {
            string str = be; str.pop_back();
            if (str.find("0") != string::npos || str.find("5") != string::npos)
            {
                cout << "1" << endl;
            }
            else
            {
                cout << "-1" << endl;
            }
        }
        else if (be[be.size()-1]=='5')
        {
            string str = be; str.pop_back();
            if (str.find("7") != string::npos || str.find("2") != string::npos)
            {
                cout << "1" << endl;
            }
            else if (ketnulla(str))
            {
                cout << "2" << endl;
            }
            else
            {
                cout << "-1" << endl;
            }
        }
        else if ((be.find("7") != string::npos && be.find("5") != string::npos) || (be.find("2") != string::npos && be.find("5") != string::npos) || (be.find("5") != string::npos && be.find("0") != string::npos) || ketnulla(be))
        {
            cout << "2" << endl;
        }
        else
        {
            cout << "-1" << endl;
        }
    }
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
subtask20/21
2Wrong answer46ms456 KiB
subtask30/23
3Wrong answer172ms568 KiB
4Wrong answer163ms688 KiB
5Wrong answer170ms672 KiB
6Wrong answer163ms644 KiB
7Wrong answer162ms440 KiB
8Wrong answer160ms624 KiB
9Wrong answer167ms452 KiB
10Wrong answer166ms640 KiB
11Wrong answer164ms568 KiB
12Wrong answer164ms464 KiB
13Wrong answer167ms508 KiB
14Wrong answer167ms568 KiB
15Wrong answer164ms508 KiB
16Wrong answer168ms556 KiB
17Wrong answer167ms464 KiB
18Wrong answer162ms452 KiB
19Wrong answer163ms568 KiB
20Wrong answer168ms568 KiB
21Wrong answer164ms456 KiB
22Wrong answer168ms444 KiB
23Wrong answer138ms784 KiB
subtask40/41
24Accepted1ms320 KiB
25Accepted1ms320 KiB
26Accepted1ms320 KiB
27Accepted1ms320 KiB
28Accepted1ms320 KiB
29Accepted1ms320 KiB
30Accepted1ms320 KiB
31Accepted1ms508 KiB
32Accepted1ms320 KiB
33Wrong answer1ms320 KiB
34Accepted1ms320 KiB
35Accepted1ms332 KiB
36Accepted3ms500 KiB
37Accepted14ms444 KiB
38Accepted1ms320 KiB
39Accepted1ms320 KiB
40Accepted1ms320 KiB
41Accepted1ms320 KiB
42Accepted2ms320 KiB
43Accepted2ms320 KiB
44Accepted2ms320 KiB
45Accepted2ms320 KiB
46Wrong answer1ms320 KiB
47Wrong answer2ms340 KiB
subtask50/15
48Wrong answer3ms440 KiB
49Wrong answer2ms676 KiB
50Wrong answer159ms456 KiB
51Wrong answer2ms468 KiB
52Wrong answer32ms428 KiB
53Accepted3ms320 KiB
54Accepted4ms448 KiB
55Accepted20ms444 KiB
56Accepted172ms720 KiB
57Accepted2ms768 KiB
58Accepted3ms588 KiB
59Accepted3ms756 KiB
60Accepted4ms320 KiB
61Accepted4ms320 KiB
62Accepted4ms320 KiB
63Accepted4ms320 KiB
64Accepted159ms704 KiB
65Accepted171ms712 KiB
66Accepted150ms568 KiB