# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
947374 | TAhmed33 | Homework (CEOI22_homework) | C++98 | 1104 ms | 234536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |