# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1088041 |
2024-09-13T18:25:55 Z |
_8_8_ |
Homework (CEOI22_homework) |
C++17 |
|
1000 ms |
128448 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6 + 12, MOD = 998244353;
string s;
int m, n, col, val[N];
vector<int> st, g[N];
bool ok[N];
int dfs(int v) {
if(v <= col) return val[v];
if(ok[v]) {
return max(dfs(g[v][0]), dfs(g[v][1]));
}
return min(dfs(g[v][0]), dfs(g[v][1]));
}
void test() {
cin >> s;
m = (int)s.size();
for(int i = 0; i < m; i++) {
if(s[i] == '?') {
col++;
}
}
n = col;
for(int i = 0; i < m; i++) {
if(s[i] == '(') {
if(!st.empty()) {
g[st.back()].push_back(n + 1);
}
st.push_back(++n);
if(s[i - 1] == 'x') {
ok[n] = 1;
}
} else if(s[i] == ')') {
st.pop_back();
}
}
int it = 0;
for(int i = col + 1; i <= n; i++) {
int f = (int)g[i].size();
for(int j = 0; j < 2 - f; j++) {
g[i].push_back(++it);
}
}
vector<int> p(col);
iota(p.begin(), p.end(), 1);
set<int> s;
do{
for(int i = 0; i < col; i++) {
val[i + 1] = p[i];
}
s.insert(dfs(col + 1));
}while(next_permutation(p.begin(), p.end()));
assert((int)s.size() == (*s.rbegin()) - (*s.begin()) + 1);
cout << (int)s.size() << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
47196 KB |
Output is correct |
2 |
Correct |
29 ms |
47192 KB |
Output is correct |
3 |
Correct |
28 ms |
47196 KB |
Output is correct |
4 |
Correct |
28 ms |
47192 KB |
Output is correct |
5 |
Correct |
29 ms |
47196 KB |
Output is correct |
6 |
Correct |
29 ms |
47196 KB |
Output is correct |
7 |
Correct |
33 ms |
47196 KB |
Output is correct |
8 |
Correct |
29 ms |
47196 KB |
Output is correct |
9 |
Correct |
28 ms |
47196 KB |
Output is correct |
10 |
Correct |
30 ms |
47196 KB |
Output is correct |
11 |
Correct |
32 ms |
47196 KB |
Output is correct |
12 |
Correct |
31 ms |
47208 KB |
Output is correct |
13 |
Correct |
30 ms |
47448 KB |
Output is correct |
14 |
Correct |
31 ms |
47196 KB |
Output is correct |
15 |
Correct |
31 ms |
47196 KB |
Output is correct |
16 |
Correct |
44 ms |
47192 KB |
Output is correct |
17 |
Correct |
33 ms |
47436 KB |
Output is correct |
18 |
Correct |
31 ms |
47196 KB |
Output is correct |
19 |
Correct |
32 ms |
47196 KB |
Output is correct |
20 |
Correct |
34 ms |
47192 KB |
Output is correct |
21 |
Correct |
30 ms |
47196 KB |
Output is correct |
22 |
Correct |
30 ms |
47196 KB |
Output is correct |
23 |
Correct |
32 ms |
47192 KB |
Output is correct |
24 |
Correct |
31 ms |
47192 KB |
Output is correct |
25 |
Correct |
21 ms |
47196 KB |
Output is correct |
26 |
Correct |
25 ms |
47196 KB |
Output is correct |
27 |
Correct |
21 ms |
47196 KB |
Output is correct |
28 |
Correct |
20 ms |
47416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
47196 KB |
Output is correct |
2 |
Correct |
29 ms |
47192 KB |
Output is correct |
3 |
Correct |
28 ms |
47196 KB |
Output is correct |
4 |
Correct |
28 ms |
47192 KB |
Output is correct |
5 |
Correct |
29 ms |
47196 KB |
Output is correct |
6 |
Correct |
29 ms |
47196 KB |
Output is correct |
7 |
Correct |
33 ms |
47196 KB |
Output is correct |
8 |
Correct |
29 ms |
47196 KB |
Output is correct |
9 |
Correct |
28 ms |
47196 KB |
Output is correct |
10 |
Correct |
30 ms |
47196 KB |
Output is correct |
11 |
Correct |
32 ms |
47196 KB |
Output is correct |
12 |
Correct |
31 ms |
47208 KB |
Output is correct |
13 |
Correct |
30 ms |
47448 KB |
Output is correct |
14 |
Correct |
31 ms |
47196 KB |
Output is correct |
15 |
Correct |
31 ms |
47196 KB |
Output is correct |
16 |
Correct |
44 ms |
47192 KB |
Output is correct |
17 |
Correct |
33 ms |
47436 KB |
Output is correct |
18 |
Correct |
31 ms |
47196 KB |
Output is correct |
19 |
Correct |
32 ms |
47196 KB |
Output is correct |
20 |
Correct |
34 ms |
47192 KB |
Output is correct |
21 |
Correct |
30 ms |
47196 KB |
Output is correct |
22 |
Correct |
30 ms |
47196 KB |
Output is correct |
23 |
Correct |
32 ms |
47192 KB |
Output is correct |
24 |
Correct |
31 ms |
47192 KB |
Output is correct |
25 |
Correct |
21 ms |
47196 KB |
Output is correct |
26 |
Correct |
25 ms |
47196 KB |
Output is correct |
27 |
Correct |
21 ms |
47196 KB |
Output is correct |
28 |
Correct |
20 ms |
47416 KB |
Output is correct |
29 |
Execution timed out |
1084 ms |
47196 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
128448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
47196 KB |
Output is correct |
2 |
Correct |
29 ms |
47192 KB |
Output is correct |
3 |
Correct |
28 ms |
47196 KB |
Output is correct |
4 |
Correct |
28 ms |
47192 KB |
Output is correct |
5 |
Correct |
29 ms |
47196 KB |
Output is correct |
6 |
Correct |
29 ms |
47196 KB |
Output is correct |
7 |
Correct |
33 ms |
47196 KB |
Output is correct |
8 |
Correct |
29 ms |
47196 KB |
Output is correct |
9 |
Correct |
28 ms |
47196 KB |
Output is correct |
10 |
Correct |
30 ms |
47196 KB |
Output is correct |
11 |
Correct |
32 ms |
47196 KB |
Output is correct |
12 |
Correct |
31 ms |
47208 KB |
Output is correct |
13 |
Correct |
30 ms |
47448 KB |
Output is correct |
14 |
Correct |
31 ms |
47196 KB |
Output is correct |
15 |
Correct |
31 ms |
47196 KB |
Output is correct |
16 |
Correct |
44 ms |
47192 KB |
Output is correct |
17 |
Correct |
33 ms |
47436 KB |
Output is correct |
18 |
Correct |
31 ms |
47196 KB |
Output is correct |
19 |
Correct |
32 ms |
47196 KB |
Output is correct |
20 |
Correct |
34 ms |
47192 KB |
Output is correct |
21 |
Correct |
30 ms |
47196 KB |
Output is correct |
22 |
Correct |
30 ms |
47196 KB |
Output is correct |
23 |
Correct |
32 ms |
47192 KB |
Output is correct |
24 |
Correct |
31 ms |
47192 KB |
Output is correct |
25 |
Correct |
21 ms |
47196 KB |
Output is correct |
26 |
Correct |
25 ms |
47196 KB |
Output is correct |
27 |
Correct |
21 ms |
47196 KB |
Output is correct |
28 |
Correct |
20 ms |
47416 KB |
Output is correct |
29 |
Execution timed out |
1084 ms |
47196 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
47196 KB |
Output is correct |
2 |
Correct |
29 ms |
47192 KB |
Output is correct |
3 |
Correct |
28 ms |
47196 KB |
Output is correct |
4 |
Correct |
28 ms |
47192 KB |
Output is correct |
5 |
Correct |
29 ms |
47196 KB |
Output is correct |
6 |
Correct |
29 ms |
47196 KB |
Output is correct |
7 |
Correct |
33 ms |
47196 KB |
Output is correct |
8 |
Correct |
29 ms |
47196 KB |
Output is correct |
9 |
Correct |
28 ms |
47196 KB |
Output is correct |
10 |
Correct |
30 ms |
47196 KB |
Output is correct |
11 |
Correct |
32 ms |
47196 KB |
Output is correct |
12 |
Correct |
31 ms |
47208 KB |
Output is correct |
13 |
Correct |
30 ms |
47448 KB |
Output is correct |
14 |
Correct |
31 ms |
47196 KB |
Output is correct |
15 |
Correct |
31 ms |
47196 KB |
Output is correct |
16 |
Correct |
44 ms |
47192 KB |
Output is correct |
17 |
Correct |
33 ms |
47436 KB |
Output is correct |
18 |
Correct |
31 ms |
47196 KB |
Output is correct |
19 |
Correct |
32 ms |
47196 KB |
Output is correct |
20 |
Correct |
34 ms |
47192 KB |
Output is correct |
21 |
Correct |
30 ms |
47196 KB |
Output is correct |
22 |
Correct |
30 ms |
47196 KB |
Output is correct |
23 |
Correct |
32 ms |
47192 KB |
Output is correct |
24 |
Correct |
31 ms |
47192 KB |
Output is correct |
25 |
Correct |
21 ms |
47196 KB |
Output is correct |
26 |
Correct |
25 ms |
47196 KB |
Output is correct |
27 |
Correct |
21 ms |
47196 KB |
Output is correct |
28 |
Correct |
20 ms |
47416 KB |
Output is correct |
29 |
Execution timed out |
1084 ms |
47196 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |