12204 | 2024-12-09 12:14:33 | Csongi | Számjegycsere | cpp17 | Wrong answer 0/100 | 171ms | 768 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 0/21 | ||||||
2 | Wrong answer | 46ms | 440 KiB | ||||
subtask3 | 0/23 | ||||||
3 | Wrong answer | 168ms | 576 KiB | ||||
4 | Wrong answer | 164ms | 568 KiB | ||||
5 | Wrong answer | 170ms | 568 KiB | ||||
6 | Wrong answer | 164ms | 568 KiB | ||||
7 | Wrong answer | 171ms | 628 KiB | ||||
8 | Wrong answer | 162ms | 568 KiB | ||||
9 | Wrong answer | 162ms | 456 KiB | ||||
10 | Wrong answer | 168ms | 580 KiB | ||||
11 | Wrong answer | 162ms | 508 KiB | ||||
12 | Wrong answer | 163ms | 500 KiB | ||||
13 | Wrong answer | 168ms | 444 KiB | ||||
14 | Wrong answer | 167ms | 444 KiB | ||||
15 | Wrong answer | 168ms | 692 KiB | ||||
16 | Wrong answer | 160ms | 444 KiB | ||||
17 | Wrong answer | 166ms | 568 KiB | ||||
18 | Wrong answer | 162ms | 440 KiB | ||||
19 | Wrong answer | 164ms | 568 KiB | ||||
20 | Wrong answer | 168ms | 468 KiB | ||||
21 | Wrong answer | 168ms | 468 KiB | ||||
22 | Wrong answer | 164ms | 568 KiB | ||||
23 | Wrong answer | 137ms | 500 KiB | ||||
subtask4 | 0/41 | ||||||
24 | Accepted | 1ms | 320 KiB | ||||
25 | Accepted | 1ms | 320 KiB | ||||
26 | Accepted | 1ms | 512 KiB | ||||
27 | Accepted | 1ms | 320 KiB | ||||
28 | Accepted | 1ms | 320 KiB | ||||
29 | Accepted | 1ms | 320 KiB | ||||
30 | Accepted | 1ms | 320 KiB | ||||
31 | Accepted | 1ms | 320 KiB | ||||
32 | Accepted | 1ms | 320 KiB | ||||
33 | Wrong answer | 1ms | 320 KiB | ||||
34 | Accepted | 1ms | 320 KiB | ||||
35 | Accepted | 1ms | 320 KiB | ||||
36 | Accepted | 2ms | 320 KiB | ||||
37 | Accepted | 14ms | 432 KiB | ||||
38 | Accepted | 1ms | 328 KiB | ||||
39 | Accepted | 1ms | 508 KiB | ||||
40 | Accepted | 1ms | 320 KiB | ||||
41 | Accepted | 1ms | 320 KiB | ||||
42 | Accepted | 2ms | 508 KiB | ||||
43 | Accepted | 2ms | 320 KiB | ||||
44 | Accepted | 2ms | 388 KiB | ||||
45 | Accepted | 2ms | 320 KiB | ||||
46 | Wrong answer | 1ms | 320 KiB | ||||
47 | Wrong answer | 2ms | 508 KiB | ||||
subtask5 | 0/15 | ||||||
48 | Wrong answer | 4ms | 320 KiB | ||||
49 | Wrong answer | 2ms | 652 KiB | ||||
50 | Wrong answer | 165ms | 588 KiB | ||||
51 | Wrong answer | 2ms | 320 KiB | ||||
52 | Wrong answer | 35ms | 448 KiB | ||||
53 | Accepted | 3ms | 320 KiB | ||||
54 | Accepted | 4ms | 320 KiB | ||||
55 | Accepted | 19ms | 448 KiB | ||||
56 | Accepted | 164ms | 708 KiB | ||||
57 | Accepted | 3ms | 696 KiB | ||||
58 | Accepted | 3ms | 576 KiB | ||||
59 | Accepted | 3ms | 768 KiB | ||||
60 | Accepted | 4ms | 320 KiB | ||||
61 | Accepted | 4ms | 320 KiB | ||||
62 | Accepted | 4ms | 320 KiB | ||||
63 | Accepted | 4ms | 320 KiB | ||||
64 | Accepted | 171ms | 716 KiB | ||||
65 | Accepted | 167ms | 716 KiB | ||||
66 | Accepted | 150ms | 568 KiB |