122052024-12-09 12:21:45CsongiSzámjegycserecpp17Wrong answer 0/100170ms724 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
1Accepted1ms500 KiB
subtask20/21
2Wrong answer46ms320 KiB
subtask30/23
3Wrong answer163ms572 KiB
4Wrong answer163ms508 KiB
5Wrong answer167ms568 KiB
6Wrong answer168ms576 KiB
7Wrong answer162ms568 KiB
8Wrong answer166ms444 KiB
9Wrong answer162ms444 KiB
10Wrong answer167ms476 KiB
11Wrong answer162ms564 KiB
12Wrong answer168ms452 KiB
13Wrong answer162ms572 KiB
14Wrong answer170ms440 KiB
15Wrong answer162ms568 KiB
16Wrong answer162ms508 KiB
17Wrong answer167ms444 KiB
18Wrong answer166ms568 KiB
19Wrong answer162ms568 KiB
20Wrong answer163ms436 KiB
21Wrong answer167ms444 KiB
22Wrong answer170ms508 KiB
23Wrong answer136ms568 KiB
subtask40/41
24Accepted1ms500 KiB
25Accepted1ms320 KiB
26Accepted1ms320 KiB
27Accepted1ms320 KiB
28Accepted1ms320 KiB
29Accepted1ms320 KiB
30Accepted1ms320 KiB
31Accepted1ms320 KiB
32Accepted1ms320 KiB
33Wrong answer1ms320 KiB
34Accepted1ms320 KiB
35Accepted1ms320 KiB
36Accepted2ms320 KiB
37Accepted14ms440 KiB
38Accepted1ms320 KiB
39Accepted1ms320 KiB
40Accepted1ms320 KiB
41Accepted1ms320 KiB
42Accepted2ms320 KiB
43Accepted3ms548 KiB
44Accepted2ms320 KiB
45Accepted2ms320 KiB
46Wrong answer1ms320 KiB
47Wrong answer2ms320 KiB
subtask50/15
48Wrong answer4ms444 KiB
49Wrong answer3ms588 KiB
50Wrong answer170ms568 KiB
51Wrong answer2ms456 KiB
52Wrong answer34ms444 KiB
53Accepted3ms320 KiB
54Accepted4ms320 KiB
55Accepted19ms448 KiB
56Accepted160ms724 KiB
57Accepted3ms588 KiB
58Accepted3ms588 KiB
59Accepted4ms588 KiB
60Accepted4ms320 KiB
61Accepted4ms320 KiB
62Accepted4ms320 KiB
63Accepted4ms408 KiB
64Accepted164ms480 KiB
65Accepted167ms700 KiB
66Accepted158ms568 KiB