122042024-12-09 12:14:33CsongiSzámjegycserecpp17Wrong answer 0/100171ms768 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 || be[be.size()-2]=='0')
            {
                cout << "1" << endl;
            }
            else if (ketnulla(str))
            {
                cout << "2" << endl;
            }
            else
            {
                cout << "-1" << endl;
            }
        }
        else if ((be[be.size()-1]=='2' && be[be.size()-2]=='5') || (be[be.size()-1]=='7' && be[be.size()-2]=='5'))
        {
            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 answer46ms440 KiB
subtask30/23
3Wrong answer168ms576 KiB
4Wrong answer164ms568 KiB
5Wrong answer170ms568 KiB
6Wrong answer164ms568 KiB
7Wrong answer171ms628 KiB
8Wrong answer162ms568 KiB
9Wrong answer162ms456 KiB
10Wrong answer168ms580 KiB
11Wrong answer162ms508 KiB
12Wrong answer163ms500 KiB
13Wrong answer168ms444 KiB
14Wrong answer167ms444 KiB
15Wrong answer168ms692 KiB
16Wrong answer160ms444 KiB
17Wrong answer166ms568 KiB
18Wrong answer162ms440 KiB
19Wrong answer164ms568 KiB
20Wrong answer168ms468 KiB
21Wrong answer168ms468 KiB
22Wrong answer164ms568 KiB
23Wrong answer137ms500 KiB
subtask40/41
24Accepted1ms320 KiB
25Accepted1ms320 KiB
26Accepted1ms512 KiB
27Accepted1ms320 KiB
28Accepted1ms320 KiB
29Accepted1ms320 KiB
30Accepted1ms320 KiB
31Accepted1ms320 KiB
32Accepted1ms320 KiB
33Wrong answer1ms320 KiB
34Accepted1ms320 KiB
35Accepted1ms320 KiB
36Accepted2ms320 KiB
37Accepted14ms432 KiB
38Accepted1ms328 KiB
39Accepted1ms508 KiB
40Accepted1ms320 KiB
41Accepted1ms320 KiB
42Accepted2ms508 KiB
43Accepted2ms320 KiB
44Accepted2ms388 KiB
45Accepted2ms320 KiB
46Wrong answer1ms320 KiB
47Wrong answer2ms508 KiB
subtask50/15
48Wrong answer4ms320 KiB
49Wrong answer2ms652 KiB
50Wrong answer165ms588 KiB
51Wrong answer2ms320 KiB
52Wrong answer35ms448 KiB
53Accepted3ms320 KiB
54Accepted4ms320 KiB
55Accepted19ms448 KiB
56Accepted164ms708 KiB
57Accepted3ms696 KiB
58Accepted3ms576 KiB
59Accepted3ms768 KiB
60Accepted4ms320 KiB
61Accepted4ms320 KiB
62Accepted4ms320 KiB
63Accepted4ms320 KiB
64Accepted171ms716 KiB
65Accepted167ms716 KiB
66Accepted150ms568 KiB