답안 #947374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947374 2024-03-16T04:20:27 Z TAhmed33 Homework (CEOI22_homework) C++
10 / 100
1000 ms 234536 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 25;
string s; deque <char> a7a;
int cnt;
vector <int> adj[MAXN];
int type[MAXN];
stack <int> cur;
vector <int> dd;
vector <int> ll2;
int dfs (int pos, int par = -1) {
	if (type[pos] == 3) {
		auto z = ll2.back(); ll2.pop_back();
		return z;
	}
	vector <int> p;
	for (auto j : adj[pos]) p.push_back(dfs(j, pos));
	if (type[pos] == 2) return *max_element(p.begin(), p.end());
	else return *min_element(p.begin(), p.end());
}
int main () {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s; 
	for (auto i : s) a7a.push_back(i); int n = 0;
	while (!a7a.empty()) {
		if (a7a.front() == ',' || a7a.front() == '(') {
			a7a.pop_front(); continue;
		}
		if (a7a.front() == ')') {
			a7a.pop_front(); cur.pop(); continue;
		}
		if (a7a[0] == 'm' && a7a[1] == 'i' && a7a[2] == 'n') {
			++cnt; if (!cur.empty()) adj[cur.top()].push_back(cnt);
			cur.push(cnt); a7a.pop_front(); a7a.pop_front(); a7a.pop_front();
			type[cnt] = 1;
			continue;
		}
		if (a7a[0] == 'm' && a7a[1] == 'a' && a7a[2] == 'x') {
			++cnt; if (!cur.empty()) adj[cur.top()].push_back(cnt);
			cur.push(cnt); a7a.pop_front(); a7a.pop_front(); a7a.pop_front();
			type[cnt] = 2;
			continue;
		}
		if (a7a[0] == '?') {
			n++;
			++cnt; if (!cur.empty()) adj[cur.top()].push_back(cnt);
			type[cnt] = 3; a7a.pop_front(); continue;
		}
	}
	for (int i = 1; i <= n; i++) dd.push_back(i);
	set <int> ans;
	do {
		ll2 = dd;
		ans.insert(dfs(1));
	} while (next_permutation(dd.begin(), dd.end()));
	cout << (int)ans.size() << '\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |  for (auto i : s) a7a.push_back(i); int n = 0;
      |  ^~~
Main.cpp:24:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |  for (auto i : s) a7a.push_back(i); int n = 0;
      |                                     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 48888 KB Output is correct
2 Correct 147 ms 48912 KB Output is correct
3 Correct 142 ms 48912 KB Output is correct
4 Correct 146 ms 48908 KB Output is correct
5 Correct 150 ms 48728 KB Output is correct
6 Correct 147 ms 48732 KB Output is correct
7 Correct 153 ms 48912 KB Output is correct
8 Correct 139 ms 48728 KB Output is correct
9 Correct 148 ms 48728 KB Output is correct
10 Correct 145 ms 48728 KB Output is correct
11 Correct 143 ms 48916 KB Output is correct
12 Correct 149 ms 48912 KB Output is correct
13 Correct 146 ms 48732 KB Output is correct
14 Correct 161 ms 48928 KB Output is correct
15 Correct 143 ms 48928 KB Output is correct
16 Correct 150 ms 48732 KB Output is correct
17 Correct 144 ms 48728 KB Output is correct
18 Correct 173 ms 48912 KB Output is correct
19 Correct 147 ms 49104 KB Output is correct
20 Correct 148 ms 48916 KB Output is correct
21 Correct 137 ms 48912 KB Output is correct
22 Correct 151 ms 48912 KB Output is correct
23 Correct 137 ms 48728 KB Output is correct
24 Correct 140 ms 48728 KB Output is correct
25 Correct 24 ms 48732 KB Output is correct
26 Correct 28 ms 48732 KB Output is correct
27 Correct 24 ms 48728 KB Output is correct
28 Correct 11 ms 48732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 48888 KB Output is correct
2 Correct 147 ms 48912 KB Output is correct
3 Correct 142 ms 48912 KB Output is correct
4 Correct 146 ms 48908 KB Output is correct
5 Correct 150 ms 48728 KB Output is correct
6 Correct 147 ms 48732 KB Output is correct
7 Correct 153 ms 48912 KB Output is correct
8 Correct 139 ms 48728 KB Output is correct
9 Correct 148 ms 48728 KB Output is correct
10 Correct 145 ms 48728 KB Output is correct
11 Correct 143 ms 48916 KB Output is correct
12 Correct 149 ms 48912 KB Output is correct
13 Correct 146 ms 48732 KB Output is correct
14 Correct 161 ms 48928 KB Output is correct
15 Correct 143 ms 48928 KB Output is correct
16 Correct 150 ms 48732 KB Output is correct
17 Correct 144 ms 48728 KB Output is correct
18 Correct 173 ms 48912 KB Output is correct
19 Correct 147 ms 49104 KB Output is correct
20 Correct 148 ms 48916 KB Output is correct
21 Correct 137 ms 48912 KB Output is correct
22 Correct 151 ms 48912 KB Output is correct
23 Correct 137 ms 48728 KB Output is correct
24 Correct 140 ms 48728 KB Output is correct
25 Correct 24 ms 48732 KB Output is correct
26 Correct 28 ms 48732 KB Output is correct
27 Correct 24 ms 48728 KB Output is correct
28 Correct 11 ms 48732 KB Output is correct
29 Execution timed out 1048 ms 48732 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1104 ms 234536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 48888 KB Output is correct
2 Correct 147 ms 48912 KB Output is correct
3 Correct 142 ms 48912 KB Output is correct
4 Correct 146 ms 48908 KB Output is correct
5 Correct 150 ms 48728 KB Output is correct
6 Correct 147 ms 48732 KB Output is correct
7 Correct 153 ms 48912 KB Output is correct
8 Correct 139 ms 48728 KB Output is correct
9 Correct 148 ms 48728 KB Output is correct
10 Correct 145 ms 48728 KB Output is correct
11 Correct 143 ms 48916 KB Output is correct
12 Correct 149 ms 48912 KB Output is correct
13 Correct 146 ms 48732 KB Output is correct
14 Correct 161 ms 48928 KB Output is correct
15 Correct 143 ms 48928 KB Output is correct
16 Correct 150 ms 48732 KB Output is correct
17 Correct 144 ms 48728 KB Output is correct
18 Correct 173 ms 48912 KB Output is correct
19 Correct 147 ms 49104 KB Output is correct
20 Correct 148 ms 48916 KB Output is correct
21 Correct 137 ms 48912 KB Output is correct
22 Correct 151 ms 48912 KB Output is correct
23 Correct 137 ms 48728 KB Output is correct
24 Correct 140 ms 48728 KB Output is correct
25 Correct 24 ms 48732 KB Output is correct
26 Correct 28 ms 48732 KB Output is correct
27 Correct 24 ms 48728 KB Output is correct
28 Correct 11 ms 48732 KB Output is correct
29 Execution timed out 1048 ms 48732 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 48888 KB Output is correct
2 Correct 147 ms 48912 KB Output is correct
3 Correct 142 ms 48912 KB Output is correct
4 Correct 146 ms 48908 KB Output is correct
5 Correct 150 ms 48728 KB Output is correct
6 Correct 147 ms 48732 KB Output is correct
7 Correct 153 ms 48912 KB Output is correct
8 Correct 139 ms 48728 KB Output is correct
9 Correct 148 ms 48728 KB Output is correct
10 Correct 145 ms 48728 KB Output is correct
11 Correct 143 ms 48916 KB Output is correct
12 Correct 149 ms 48912 KB Output is correct
13 Correct 146 ms 48732 KB Output is correct
14 Correct 161 ms 48928 KB Output is correct
15 Correct 143 ms 48928 KB Output is correct
16 Correct 150 ms 48732 KB Output is correct
17 Correct 144 ms 48728 KB Output is correct
18 Correct 173 ms 48912 KB Output is correct
19 Correct 147 ms 49104 KB Output is correct
20 Correct 148 ms 48916 KB Output is correct
21 Correct 137 ms 48912 KB Output is correct
22 Correct 151 ms 48912 KB Output is correct
23 Correct 137 ms 48728 KB Output is correct
24 Correct 140 ms 48728 KB Output is correct
25 Correct 24 ms 48732 KB Output is correct
26 Correct 28 ms 48732 KB Output is correct
27 Correct 24 ms 48728 KB Output is correct
28 Correct 11 ms 48732 KB Output is correct
29 Execution timed out 1048 ms 48732 KB Time limit exceeded
30 Halted 0 ms 0 KB -