Submission #709192

# Submission time Handle Problem Language Result Execution time Memory
709192 2023-03-13T07:44:23 Z vjudge1 Homework (CEOI22_homework) C++17
10 / 100
1000 ms 22596 KB
#include<bits/stdc++.h>

#define x first
#define y second
#define sz(v) (int)v.size()
#define pb push_back
#define nl "\n"

using namespace std;

const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;
     
int n, pos[N], p[N], e[N];
string s;

int calc(int l, int r) {
	if(l == r) {
		return p[pos[l]];
	}		
	bool tp = (s[l + 1] == 'a');                 
	int mid = e[l];
	if(tp) return max(calc(l + 4, mid - 1), calc(mid + 1, r - 1));
	else return min(calc(l + 4, mid - 1), calc(mid + 1, r - 1));	
}

int main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cin >> s;
	for(int i = 0; i < sz(s); ++i) {
		if(s[i] == '?') {
			pos[i] = ++n;
		}
	}
	stack<int> st;
	for(int i = 0; i < sz(s); ++i) {
		if(s[i] == 'm') st.push(i);		
		if(s[i] == ',') {
			assert(!st.empty());
			e[st.top()] = i;
			st.pop();
		}
	}
	for(int i = 1; i <= n; ++i) p[i] = i;
	set<int> se;
	do {
		int val = calc(0, sz(s) - 1);
		se.insert(val);					
	} while(next_permutation(p + 1, p + 1 + n));
	cout << sz(se) << nl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 336 KB Output is correct
2 Correct 20 ms 328 KB Output is correct
3 Correct 17 ms 340 KB Output is correct
4 Correct 21 ms 212 KB Output is correct
5 Correct 27 ms 340 KB Output is correct
6 Correct 22 ms 340 KB Output is correct
7 Correct 23 ms 212 KB Output is correct
8 Correct 20 ms 340 KB Output is correct
9 Correct 21 ms 212 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 22 ms 340 KB Output is correct
12 Correct 21 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 23 ms 212 KB Output is correct
15 Correct 22 ms 324 KB Output is correct
16 Correct 23 ms 340 KB Output is correct
17 Correct 30 ms 340 KB Output is correct
18 Correct 19 ms 340 KB Output is correct
19 Correct 20 ms 212 KB Output is correct
20 Correct 24 ms 340 KB Output is correct
21 Correct 19 ms 344 KB Output is correct
22 Correct 20 ms 340 KB Output is correct
23 Correct 23 ms 324 KB Output is correct
24 Correct 22 ms 328 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 336 KB Output is correct
2 Correct 20 ms 328 KB Output is correct
3 Correct 17 ms 340 KB Output is correct
4 Correct 21 ms 212 KB Output is correct
5 Correct 27 ms 340 KB Output is correct
6 Correct 22 ms 340 KB Output is correct
7 Correct 23 ms 212 KB Output is correct
8 Correct 20 ms 340 KB Output is correct
9 Correct 21 ms 212 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 22 ms 340 KB Output is correct
12 Correct 21 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 23 ms 212 KB Output is correct
15 Correct 22 ms 324 KB Output is correct
16 Correct 23 ms 340 KB Output is correct
17 Correct 30 ms 340 KB Output is correct
18 Correct 19 ms 340 KB Output is correct
19 Correct 20 ms 212 KB Output is correct
20 Correct 24 ms 340 KB Output is correct
21 Correct 19 ms 344 KB Output is correct
22 Correct 20 ms 340 KB Output is correct
23 Correct 23 ms 324 KB Output is correct
24 Correct 22 ms 328 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Execution timed out 1071 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 22596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 336 KB Output is correct
2 Correct 20 ms 328 KB Output is correct
3 Correct 17 ms 340 KB Output is correct
4 Correct 21 ms 212 KB Output is correct
5 Correct 27 ms 340 KB Output is correct
6 Correct 22 ms 340 KB Output is correct
7 Correct 23 ms 212 KB Output is correct
8 Correct 20 ms 340 KB Output is correct
9 Correct 21 ms 212 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 22 ms 340 KB Output is correct
12 Correct 21 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 23 ms 212 KB Output is correct
15 Correct 22 ms 324 KB Output is correct
16 Correct 23 ms 340 KB Output is correct
17 Correct 30 ms 340 KB Output is correct
18 Correct 19 ms 340 KB Output is correct
19 Correct 20 ms 212 KB Output is correct
20 Correct 24 ms 340 KB Output is correct
21 Correct 19 ms 344 KB Output is correct
22 Correct 20 ms 340 KB Output is correct
23 Correct 23 ms 324 KB Output is correct
24 Correct 22 ms 328 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Execution timed out 1071 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 336 KB Output is correct
2 Correct 20 ms 328 KB Output is correct
3 Correct 17 ms 340 KB Output is correct
4 Correct 21 ms 212 KB Output is correct
5 Correct 27 ms 340 KB Output is correct
6 Correct 22 ms 340 KB Output is correct
7 Correct 23 ms 212 KB Output is correct
8 Correct 20 ms 340 KB Output is correct
9 Correct 21 ms 212 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 22 ms 340 KB Output is correct
12 Correct 21 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 23 ms 212 KB Output is correct
15 Correct 22 ms 324 KB Output is correct
16 Correct 23 ms 340 KB Output is correct
17 Correct 30 ms 340 KB Output is correct
18 Correct 19 ms 340 KB Output is correct
19 Correct 20 ms 212 KB Output is correct
20 Correct 24 ms 340 KB Output is correct
21 Correct 19 ms 344 KB Output is correct
22 Correct 20 ms 340 KB Output is correct
23 Correct 23 ms 324 KB Output is correct
24 Correct 22 ms 328 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Execution timed out 1071 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -