#include <bits/stdc++.h>
using namespace std;
int n,res; string s;
vector <vector <int>> perms;
bool vis[10];
void add(int a[])
{
vector <int> act;
for(int i=0; i<n; i++)
act.push_back(a[i]);
perms.push_back(act);
}
void calc(int a[])
{
do
add(a);
while (next_permutation(a,a+n));
}
bool isnum(char x)
{
return (x > 48 && x < 58);
}
int check(vector <int> act)
{
int it = 0;
string st = "";
for(int i=0; i<s.size(); i++)
{
if(s[i] != 'm' && s[i] != 'i' && s[i] != 'a')
st += s[i];
}
for(int i=0; i<st.size(); i++)
{
if(st[i] == '?')
{
st[i] = (act[it]+48);
it++;
}
}
while(st.size() != 1)
{
for(int i=3; i<st.size(); i++)
{
if(st[i] == ',' && isnum(st[i+1]) && isnum(st[i-1]))
{
if(st[i-3] == 'n')
{
st[i-3] = min(st[i+1], st[i-1]);
st.erase(i-2, 5);
}
else
{
st[i-3] = max(st[i+1], st[i-1]);
st.erase(i-2, 5);
}
break;
}
}
}
return (st[0]-48);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s;
for(int i=0; i<s.size(); i++)
if(s[i] == '?') n++;
int perm[n];
for(int i=0; i<n; i++)
perm[i] = i+1;
calc(perm);
for(int i=0; i<perms.size(); i++)
{
int temp = check(perms[i]);
if(!vis[temp])
{
res++;
vis[temp] = 1;
}
}
cout << res;
}
Compilation message
Main.cpp: In function 'int check(std::vector<int>)':
Main.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i=0; i<s.size(); i++)
| ~^~~~~~~~~
Main.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i=0; i<st.size(); i++)
| ~^~~~~~~~~~
Main.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=3; i<st.size(); i++)
| ~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:82:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | for(int i=0; i<s.size(); i++)
| ~^~~~~~~~~
Main.cpp:91:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
91 | for(int i=0; i<perms.size(); i++)
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
25832 KB |
Output is correct |
2 |
Correct |
243 ms |
25788 KB |
Output is correct |
3 |
Correct |
231 ms |
25820 KB |
Output is correct |
4 |
Correct |
228 ms |
25832 KB |
Output is correct |
5 |
Correct |
237 ms |
25852 KB |
Output is correct |
6 |
Correct |
250 ms |
25820 KB |
Output is correct |
7 |
Correct |
242 ms |
25792 KB |
Output is correct |
8 |
Correct |
238 ms |
25832 KB |
Output is correct |
9 |
Correct |
229 ms |
25804 KB |
Output is correct |
10 |
Correct |
237 ms |
25780 KB |
Output is correct |
11 |
Correct |
236 ms |
25876 KB |
Output is correct |
12 |
Correct |
230 ms |
25816 KB |
Output is correct |
13 |
Correct |
244 ms |
25800 KB |
Output is correct |
14 |
Correct |
231 ms |
25860 KB |
Output is correct |
15 |
Correct |
231 ms |
25852 KB |
Output is correct |
16 |
Correct |
243 ms |
25860 KB |
Output is correct |
17 |
Correct |
245 ms |
25792 KB |
Output is correct |
18 |
Correct |
236 ms |
25848 KB |
Output is correct |
19 |
Correct |
246 ms |
25832 KB |
Output is correct |
20 |
Correct |
241 ms |
25808 KB |
Output is correct |
21 |
Correct |
231 ms |
25844 KB |
Output is correct |
22 |
Correct |
230 ms |
25768 KB |
Output is correct |
23 |
Correct |
250 ms |
25800 KB |
Output is correct |
24 |
Correct |
232 ms |
25804 KB |
Output is correct |
25 |
Correct |
24 ms |
3340 KB |
Output is correct |
26 |
Correct |
23 ms |
3356 KB |
Output is correct |
27 |
Correct |
23 ms |
3340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
25832 KB |
Output is correct |
2 |
Correct |
243 ms |
25788 KB |
Output is correct |
3 |
Correct |
231 ms |
25820 KB |
Output is correct |
4 |
Correct |
228 ms |
25832 KB |
Output is correct |
5 |
Correct |
237 ms |
25852 KB |
Output is correct |
6 |
Correct |
250 ms |
25820 KB |
Output is correct |
7 |
Correct |
242 ms |
25792 KB |
Output is correct |
8 |
Correct |
238 ms |
25832 KB |
Output is correct |
9 |
Correct |
229 ms |
25804 KB |
Output is correct |
10 |
Correct |
237 ms |
25780 KB |
Output is correct |
11 |
Correct |
236 ms |
25876 KB |
Output is correct |
12 |
Correct |
230 ms |
25816 KB |
Output is correct |
13 |
Correct |
244 ms |
25800 KB |
Output is correct |
14 |
Correct |
231 ms |
25860 KB |
Output is correct |
15 |
Correct |
231 ms |
25852 KB |
Output is correct |
16 |
Correct |
243 ms |
25860 KB |
Output is correct |
17 |
Correct |
245 ms |
25792 KB |
Output is correct |
18 |
Correct |
236 ms |
25848 KB |
Output is correct |
19 |
Correct |
246 ms |
25832 KB |
Output is correct |
20 |
Correct |
241 ms |
25808 KB |
Output is correct |
21 |
Correct |
231 ms |
25844 KB |
Output is correct |
22 |
Correct |
230 ms |
25768 KB |
Output is correct |
23 |
Correct |
250 ms |
25800 KB |
Output is correct |
24 |
Correct |
232 ms |
25804 KB |
Output is correct |
25 |
Correct |
24 ms |
3340 KB |
Output is correct |
26 |
Correct |
23 ms |
3356 KB |
Output is correct |
27 |
Correct |
23 ms |
3340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Execution timed out |
1071 ms |
524288 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
654 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
25832 KB |
Output is correct |
2 |
Correct |
243 ms |
25788 KB |
Output is correct |
3 |
Correct |
231 ms |
25820 KB |
Output is correct |
4 |
Correct |
228 ms |
25832 KB |
Output is correct |
5 |
Correct |
237 ms |
25852 KB |
Output is correct |
6 |
Correct |
250 ms |
25820 KB |
Output is correct |
7 |
Correct |
242 ms |
25792 KB |
Output is correct |
8 |
Correct |
238 ms |
25832 KB |
Output is correct |
9 |
Correct |
229 ms |
25804 KB |
Output is correct |
10 |
Correct |
237 ms |
25780 KB |
Output is correct |
11 |
Correct |
236 ms |
25876 KB |
Output is correct |
12 |
Correct |
230 ms |
25816 KB |
Output is correct |
13 |
Correct |
244 ms |
25800 KB |
Output is correct |
14 |
Correct |
231 ms |
25860 KB |
Output is correct |
15 |
Correct |
231 ms |
25852 KB |
Output is correct |
16 |
Correct |
243 ms |
25860 KB |
Output is correct |
17 |
Correct |
245 ms |
25792 KB |
Output is correct |
18 |
Correct |
236 ms |
25848 KB |
Output is correct |
19 |
Correct |
246 ms |
25832 KB |
Output is correct |
20 |
Correct |
241 ms |
25808 KB |
Output is correct |
21 |
Correct |
231 ms |
25844 KB |
Output is correct |
22 |
Correct |
230 ms |
25768 KB |
Output is correct |
23 |
Correct |
250 ms |
25800 KB |
Output is correct |
24 |
Correct |
232 ms |
25804 KB |
Output is correct |
25 |
Correct |
24 ms |
3340 KB |
Output is correct |
26 |
Correct |
23 ms |
3356 KB |
Output is correct |
27 |
Correct |
23 ms |
3340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Execution timed out |
1071 ms |
524288 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
25832 KB |
Output is correct |
2 |
Correct |
243 ms |
25788 KB |
Output is correct |
3 |
Correct |
231 ms |
25820 KB |
Output is correct |
4 |
Correct |
228 ms |
25832 KB |
Output is correct |
5 |
Correct |
237 ms |
25852 KB |
Output is correct |
6 |
Correct |
250 ms |
25820 KB |
Output is correct |
7 |
Correct |
242 ms |
25792 KB |
Output is correct |
8 |
Correct |
238 ms |
25832 KB |
Output is correct |
9 |
Correct |
229 ms |
25804 KB |
Output is correct |
10 |
Correct |
237 ms |
25780 KB |
Output is correct |
11 |
Correct |
236 ms |
25876 KB |
Output is correct |
12 |
Correct |
230 ms |
25816 KB |
Output is correct |
13 |
Correct |
244 ms |
25800 KB |
Output is correct |
14 |
Correct |
231 ms |
25860 KB |
Output is correct |
15 |
Correct |
231 ms |
25852 KB |
Output is correct |
16 |
Correct |
243 ms |
25860 KB |
Output is correct |
17 |
Correct |
245 ms |
25792 KB |
Output is correct |
18 |
Correct |
236 ms |
25848 KB |
Output is correct |
19 |
Correct |
246 ms |
25832 KB |
Output is correct |
20 |
Correct |
241 ms |
25808 KB |
Output is correct |
21 |
Correct |
231 ms |
25844 KB |
Output is correct |
22 |
Correct |
230 ms |
25768 KB |
Output is correct |
23 |
Correct |
250 ms |
25800 KB |
Output is correct |
24 |
Correct |
232 ms |
25804 KB |
Output is correct |
25 |
Correct |
24 ms |
3340 KB |
Output is correct |
26 |
Correct |
23 ms |
3356 KB |
Output is correct |
27 |
Correct |
23 ms |
3340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Execution timed out |
1071 ms |
524288 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |