-
Notifications
You must be signed in to change notification settings - Fork 478
/
Copy path1593B.cpp
50 lines (48 loc) · 1.36 KB
/
1593B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//🎃🎃🎃😎😎😁🤓☣☣☣☣☣dark_coder☣☣☣☣☣😎😎😁🤓🎃🎃🎃
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define li long long int
#define pi pair<int, int>
int main()
{
IOS int t;
cin >> t;
while (t--)
{
string s;
cin >> s;
int indi[6] = {20, 20, 20, 20, 20, 20}, flag1 = 1, flag2 = 1, flag3 = 1;
reverse(all(s));
for (int i = 0; i < s.length(); i++)
{
/* code */
if (s[i] == '0' )
{
for (int j = i + 1; j < s.length(); j++)
{
if ((s[j] == '5'||s[j]=='0')&& indi[5]==20)
{
indi[5] = j - 1;
}
}
}
else if (s[i] == '5')
{
for (int j = i + 1; j < s.length(); j++)
{
if ((s[j] == '2' || s[j] == '7') && (indi[4]==20))
{
indi[4] = j - 1;
}
}
}
}
cout << min(indi[3],min(indi[4],indi[5])) << endl;
}
return 0;
}