답안 #971251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971251 2024-04-28T08:55:45 Z vjudge1 Homework (CEOI22_homework) C++17
10 / 100
1000 ms 124188 KB
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

int main() {
    string s;
    cin >> s;
    int n = 0, m = 0;
    vector<array<int, 2> > Fii;
    vector<int> Tip;/// -1 -> min; 0 -> valoare; 1 -> maxim
    int ultp = 0;
    function<int(int)> parse = [&](int poz) -> int {
        /// va crea un nod cu expresia care incepe la poz
        while(s[poz] == ',' || s[poz] == '(' || s[poz] == ')') ++poz;
        ultp = max(ultp, poz);
        ++n;
        if(s[poz] == '?') {
            ++m;
            Fii.push_back({-1, -1});
            Tip.emplace_back(0);
            return int(Tip.size()) - 1;
        }
        int f1 = parse(poz + 4), f2 = parse(ultp + 1);
        if(s[poz + 1] == 'i') Tip.emplace_back(-1);
        else Tip.emplace_back(1);
        Fii.push_back({f1, f2});
        return int(Tip.size()) - 1;
    };
    int rad = parse(0);
    vi P;
    for(int i = 0; i < m; ++i)
        P.push_back(i);
    set<int> S;
    do {
        int p = 0;
        function<int(int)> eval = [&](int u) {
            if(Tip[u] == 0) {
                return P[p++];
            }
            int v1 = eval(Fii[u][0]), v2 = eval(Fii[u][1]);
            if(Tip[u] == -1) return min(v1, v2);
            return max(v1, v2);
        };
        S.insert(eval(rad));
    } while(next_permutation(P.begin(), P.end()));
    cout << S.size() << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 344 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 38 ms 348 KB Output is correct
4 Correct 42 ms 348 KB Output is correct
5 Correct 40 ms 348 KB Output is correct
6 Correct 48 ms 596 KB Output is correct
7 Correct 46 ms 344 KB Output is correct
8 Correct 39 ms 344 KB Output is correct
9 Correct 39 ms 348 KB Output is correct
10 Correct 40 ms 348 KB Output is correct
11 Correct 39 ms 348 KB Output is correct
12 Correct 52 ms 348 KB Output is correct
13 Correct 43 ms 412 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 40 ms 344 KB Output is correct
16 Correct 41 ms 348 KB Output is correct
17 Correct 47 ms 344 KB Output is correct
18 Correct 39 ms 344 KB Output is correct
19 Correct 39 ms 424 KB Output is correct
20 Correct 41 ms 348 KB Output is correct
21 Correct 39 ms 344 KB Output is correct
22 Correct 39 ms 348 KB Output is correct
23 Correct 40 ms 348 KB Output is correct
24 Correct 40 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 344 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 38 ms 348 KB Output is correct
4 Correct 42 ms 348 KB Output is correct
5 Correct 40 ms 348 KB Output is correct
6 Correct 48 ms 596 KB Output is correct
7 Correct 46 ms 344 KB Output is correct
8 Correct 39 ms 344 KB Output is correct
9 Correct 39 ms 348 KB Output is correct
10 Correct 40 ms 348 KB Output is correct
11 Correct 39 ms 348 KB Output is correct
12 Correct 52 ms 348 KB Output is correct
13 Correct 43 ms 412 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 40 ms 344 KB Output is correct
16 Correct 41 ms 348 KB Output is correct
17 Correct 47 ms 344 KB Output is correct
18 Correct 39 ms 344 KB Output is correct
19 Correct 39 ms 424 KB Output is correct
20 Correct 41 ms 348 KB Output is correct
21 Correct 39 ms 344 KB Output is correct
22 Correct 39 ms 348 KB Output is correct
23 Correct 40 ms 348 KB Output is correct
24 Correct 40 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1082 ms 344 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 124188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 344 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 38 ms 348 KB Output is correct
4 Correct 42 ms 348 KB Output is correct
5 Correct 40 ms 348 KB Output is correct
6 Correct 48 ms 596 KB Output is correct
7 Correct 46 ms 344 KB Output is correct
8 Correct 39 ms 344 KB Output is correct
9 Correct 39 ms 348 KB Output is correct
10 Correct 40 ms 348 KB Output is correct
11 Correct 39 ms 348 KB Output is correct
12 Correct 52 ms 348 KB Output is correct
13 Correct 43 ms 412 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 40 ms 344 KB Output is correct
16 Correct 41 ms 348 KB Output is correct
17 Correct 47 ms 344 KB Output is correct
18 Correct 39 ms 344 KB Output is correct
19 Correct 39 ms 424 KB Output is correct
20 Correct 41 ms 348 KB Output is correct
21 Correct 39 ms 344 KB Output is correct
22 Correct 39 ms 348 KB Output is correct
23 Correct 40 ms 348 KB Output is correct
24 Correct 40 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1082 ms 344 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 344 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 38 ms 348 KB Output is correct
4 Correct 42 ms 348 KB Output is correct
5 Correct 40 ms 348 KB Output is correct
6 Correct 48 ms 596 KB Output is correct
7 Correct 46 ms 344 KB Output is correct
8 Correct 39 ms 344 KB Output is correct
9 Correct 39 ms 348 KB Output is correct
10 Correct 40 ms 348 KB Output is correct
11 Correct 39 ms 348 KB Output is correct
12 Correct 52 ms 348 KB Output is correct
13 Correct 43 ms 412 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 40 ms 344 KB Output is correct
16 Correct 41 ms 348 KB Output is correct
17 Correct 47 ms 344 KB Output is correct
18 Correct 39 ms 344 KB Output is correct
19 Correct 39 ms 424 KB Output is correct
20 Correct 41 ms 348 KB Output is correct
21 Correct 39 ms 344 KB Output is correct
22 Correct 39 ms 348 KB Output is correct
23 Correct 40 ms 348 KB Output is correct
24 Correct 40 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1082 ms 344 KB Time limit exceeded
30 Halted 0 ms 0 KB -