# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1014726 |
2024-07-05T10:51:16 Z |
atom |
Homework (CEOI22_homework) |
C++17 |
|
1000 ms |
131740 KB |
#include "bits/stdc++.h"
// @JASPER'S BOILERPLATE
using namespace std;
using ll = long long;
#ifdef JASPER
#include "debug.h"
#else
#define debug(...) 166
#endif
const int N = 1e6 + 5;
int n, sz;
string s;
vector <int> c;
struct Node {
int t;
Node *l, *r;
Node() {
t = -1;
l = r = nullptr;
}
};
Node* make(int& i) {
Node* cur = new Node();
if (s[i] == '?') {
++i;
cur->t = n++;
return cur;
}
if (s[i + 1] == 'i') {
cur->t = -1;
}
else {
cur->t = -2;
}
i += 4;
cur->l = make(i);
++i;
cur->r = make(i);
++i;
return cur;
}
int dfs(Node* tr) {
if (tr->t >= 0)
return c[tr->t];
int x = 0, y = 0;
if (tr->l != nullptr)
x = dfs(tr->l);
if (tr->r != nullptr)
y = dfs(tr->r);
if (tr->t == -1) return min(x, y);
else return max(x, y);
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#ifdef JASPER
freopen("in1", "r", stdin);
#endif
cin >> s;
sz = s.size();
int p = 0;
Node* tr = make(p);
c.resize(n);
iota(c.begin(), c.end(), 1);
vector <int> vals;
do {
vals.push_back(dfs(tr));
} while (next_permutation(c.begin(), c.end()));
sort(vals.begin(), vals.end());
vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
cout << (int) vals.size() << "\n";
// cout << dfs(tr) << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2516 KB |
Output is correct |
2 |
Correct |
16 ms |
2520 KB |
Output is correct |
3 |
Correct |
17 ms |
2628 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
17 ms |
2520 KB |
Output is correct |
6 |
Correct |
17 ms |
2468 KB |
Output is correct |
7 |
Correct |
17 ms |
2520 KB |
Output is correct |
8 |
Correct |
16 ms |
2520 KB |
Output is correct |
9 |
Correct |
16 ms |
2520 KB |
Output is correct |
10 |
Correct |
18 ms |
2492 KB |
Output is correct |
11 |
Correct |
15 ms |
2520 KB |
Output is correct |
12 |
Correct |
15 ms |
2592 KB |
Output is correct |
13 |
Correct |
15 ms |
2452 KB |
Output is correct |
14 |
Correct |
16 ms |
2520 KB |
Output is correct |
15 |
Correct |
17 ms |
2516 KB |
Output is correct |
16 |
Correct |
22 ms |
2620 KB |
Output is correct |
17 |
Correct |
17 ms |
2516 KB |
Output is correct |
18 |
Correct |
15 ms |
2520 KB |
Output is correct |
19 |
Correct |
21 ms |
2624 KB |
Output is correct |
20 |
Correct |
19 ms |
2520 KB |
Output is correct |
21 |
Correct |
15 ms |
2516 KB |
Output is correct |
22 |
Correct |
17 ms |
2536 KB |
Output is correct |
23 |
Correct |
15 ms |
2520 KB |
Output is correct |
24 |
Correct |
22 ms |
2520 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
4 ms |
736 KB |
Output is correct |
28 |
Correct |
0 ms |
424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2516 KB |
Output is correct |
2 |
Correct |
16 ms |
2520 KB |
Output is correct |
3 |
Correct |
17 ms |
2628 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
17 ms |
2520 KB |
Output is correct |
6 |
Correct |
17 ms |
2468 KB |
Output is correct |
7 |
Correct |
17 ms |
2520 KB |
Output is correct |
8 |
Correct |
16 ms |
2520 KB |
Output is correct |
9 |
Correct |
16 ms |
2520 KB |
Output is correct |
10 |
Correct |
18 ms |
2492 KB |
Output is correct |
11 |
Correct |
15 ms |
2520 KB |
Output is correct |
12 |
Correct |
15 ms |
2592 KB |
Output is correct |
13 |
Correct |
15 ms |
2452 KB |
Output is correct |
14 |
Correct |
16 ms |
2520 KB |
Output is correct |
15 |
Correct |
17 ms |
2516 KB |
Output is correct |
16 |
Correct |
22 ms |
2620 KB |
Output is correct |
17 |
Correct |
17 ms |
2516 KB |
Output is correct |
18 |
Correct |
15 ms |
2520 KB |
Output is correct |
19 |
Correct |
21 ms |
2624 KB |
Output is correct |
20 |
Correct |
19 ms |
2520 KB |
Output is correct |
21 |
Correct |
15 ms |
2516 KB |
Output is correct |
22 |
Correct |
17 ms |
2536 KB |
Output is correct |
23 |
Correct |
15 ms |
2520 KB |
Output is correct |
24 |
Correct |
22 ms |
2520 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
4 ms |
736 KB |
Output is correct |
28 |
Correct |
0 ms |
424 KB |
Output is correct |
29 |
Execution timed out |
1073 ms |
131740 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1036 ms |
111900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2516 KB |
Output is correct |
2 |
Correct |
16 ms |
2520 KB |
Output is correct |
3 |
Correct |
17 ms |
2628 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
17 ms |
2520 KB |
Output is correct |
6 |
Correct |
17 ms |
2468 KB |
Output is correct |
7 |
Correct |
17 ms |
2520 KB |
Output is correct |
8 |
Correct |
16 ms |
2520 KB |
Output is correct |
9 |
Correct |
16 ms |
2520 KB |
Output is correct |
10 |
Correct |
18 ms |
2492 KB |
Output is correct |
11 |
Correct |
15 ms |
2520 KB |
Output is correct |
12 |
Correct |
15 ms |
2592 KB |
Output is correct |
13 |
Correct |
15 ms |
2452 KB |
Output is correct |
14 |
Correct |
16 ms |
2520 KB |
Output is correct |
15 |
Correct |
17 ms |
2516 KB |
Output is correct |
16 |
Correct |
22 ms |
2620 KB |
Output is correct |
17 |
Correct |
17 ms |
2516 KB |
Output is correct |
18 |
Correct |
15 ms |
2520 KB |
Output is correct |
19 |
Correct |
21 ms |
2624 KB |
Output is correct |
20 |
Correct |
19 ms |
2520 KB |
Output is correct |
21 |
Correct |
15 ms |
2516 KB |
Output is correct |
22 |
Correct |
17 ms |
2536 KB |
Output is correct |
23 |
Correct |
15 ms |
2520 KB |
Output is correct |
24 |
Correct |
22 ms |
2520 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
4 ms |
736 KB |
Output is correct |
28 |
Correct |
0 ms |
424 KB |
Output is correct |
29 |
Execution timed out |
1073 ms |
131740 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2516 KB |
Output is correct |
2 |
Correct |
16 ms |
2520 KB |
Output is correct |
3 |
Correct |
17 ms |
2628 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
17 ms |
2520 KB |
Output is correct |
6 |
Correct |
17 ms |
2468 KB |
Output is correct |
7 |
Correct |
17 ms |
2520 KB |
Output is correct |
8 |
Correct |
16 ms |
2520 KB |
Output is correct |
9 |
Correct |
16 ms |
2520 KB |
Output is correct |
10 |
Correct |
18 ms |
2492 KB |
Output is correct |
11 |
Correct |
15 ms |
2520 KB |
Output is correct |
12 |
Correct |
15 ms |
2592 KB |
Output is correct |
13 |
Correct |
15 ms |
2452 KB |
Output is correct |
14 |
Correct |
16 ms |
2520 KB |
Output is correct |
15 |
Correct |
17 ms |
2516 KB |
Output is correct |
16 |
Correct |
22 ms |
2620 KB |
Output is correct |
17 |
Correct |
17 ms |
2516 KB |
Output is correct |
18 |
Correct |
15 ms |
2520 KB |
Output is correct |
19 |
Correct |
21 ms |
2624 KB |
Output is correct |
20 |
Correct |
19 ms |
2520 KB |
Output is correct |
21 |
Correct |
15 ms |
2516 KB |
Output is correct |
22 |
Correct |
17 ms |
2536 KB |
Output is correct |
23 |
Correct |
15 ms |
2520 KB |
Output is correct |
24 |
Correct |
22 ms |
2520 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
4 ms |
736 KB |
Output is correct |
28 |
Correct |
0 ms |
424 KB |
Output is correct |
29 |
Execution timed out |
1073 ms |
131740 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |