Submission #830361

# Submission time Handle Problem Language Result Execution time Memory
830361 2023-08-19T04:33:28 Z peteza Homework (CEOI22_homework) C++14
10 / 100
1000 ms 43804 KB
#include <bits/stdc++.h>
using namespace std;

string str;
int bin[1000005][2];
int type[1000005];
int cnode = 0;
stack<int> stk;
set<int> S;
vector<int> vec;

int ci = 0;

int dfs(int x) {
    if(type[x] == 2) return vec[ci++];
    int e1 = dfs(bin[x][0]), e2 = dfs(bin[x][1]);
    return (type[x] ? max(e1, e2) : min(e1, e2));
}

int main() {
    cin >> str; 
    for(int i=0;i<str.size();) {
        if(str[i] == ',' || str[i]=='('){i++; continue;}
        if(str[i] == 'm') {
            stk.push(cnode);
            if(str[i+1] == 'i') { //minimum
                type[cnode++] = 0;
            } else {
                type[cnode++] = 1;
            }
            i += 4;
        } else if(str[i] == '?') {
            stk.push(cnode);
            type[cnode++] = 2;
            i++;
        } else {
            int e1 = stk.top(); stk.pop();
            int e2 = stk.top(); stk.pop();
            bin[stk.top()][0] = e2; bin[stk.top()][1] = e1;
            i++;
        }
    }
    for(int i=1;i<=count(str.begin(), str.end(), '?');i++) vec.push_back(i);
    //for(int i=0;i<cnode;i++) cout << bin[i][0] << ' ' << bin[i][1] << '\n';
    do {
        ci = 0;
        S.insert(dfs(0));
    } while (next_permutation(vec.begin(), vec.end()));
    cout << S.size();
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0;i<str.size();) {
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 212 KB Output is correct
2 Correct 23 ms 320 KB Output is correct
3 Correct 18 ms 296 KB Output is correct
4 Correct 18 ms 300 KB Output is correct
5 Correct 19 ms 212 KB Output is correct
6 Correct 19 ms 212 KB Output is correct
7 Correct 20 ms 324 KB Output is correct
8 Correct 18 ms 316 KB Output is correct
9 Correct 17 ms 212 KB Output is correct
10 Correct 20 ms 316 KB Output is correct
11 Correct 19 ms 212 KB Output is correct
12 Correct 21 ms 212 KB Output is correct
13 Correct 19 ms 212 KB Output is correct
14 Correct 19 ms 316 KB Output is correct
15 Correct 19 ms 320 KB Output is correct
16 Correct 19 ms 212 KB Output is correct
17 Correct 24 ms 212 KB Output is correct
18 Correct 18 ms 308 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 21 ms 304 KB Output is correct
21 Correct 18 ms 316 KB Output is correct
22 Correct 18 ms 308 KB Output is correct
23 Correct 18 ms 316 KB Output is correct
24 Correct 18 ms 320 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 212 KB Output is correct
2 Correct 23 ms 320 KB Output is correct
3 Correct 18 ms 296 KB Output is correct
4 Correct 18 ms 300 KB Output is correct
5 Correct 19 ms 212 KB Output is correct
6 Correct 19 ms 212 KB Output is correct
7 Correct 20 ms 324 KB Output is correct
8 Correct 18 ms 316 KB Output is correct
9 Correct 17 ms 212 KB Output is correct
10 Correct 20 ms 316 KB Output is correct
11 Correct 19 ms 212 KB Output is correct
12 Correct 21 ms 212 KB Output is correct
13 Correct 19 ms 212 KB Output is correct
14 Correct 19 ms 316 KB Output is correct
15 Correct 19 ms 320 KB Output is correct
16 Correct 19 ms 212 KB Output is correct
17 Correct 24 ms 212 KB Output is correct
18 Correct 18 ms 308 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 21 ms 304 KB Output is correct
21 Correct 18 ms 316 KB Output is correct
22 Correct 18 ms 308 KB Output is correct
23 Correct 18 ms 316 KB Output is correct
24 Correct 18 ms 320 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Execution timed out 1079 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 141 ms 43804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 212 KB Output is correct
2 Correct 23 ms 320 KB Output is correct
3 Correct 18 ms 296 KB Output is correct
4 Correct 18 ms 300 KB Output is correct
5 Correct 19 ms 212 KB Output is correct
6 Correct 19 ms 212 KB Output is correct
7 Correct 20 ms 324 KB Output is correct
8 Correct 18 ms 316 KB Output is correct
9 Correct 17 ms 212 KB Output is correct
10 Correct 20 ms 316 KB Output is correct
11 Correct 19 ms 212 KB Output is correct
12 Correct 21 ms 212 KB Output is correct
13 Correct 19 ms 212 KB Output is correct
14 Correct 19 ms 316 KB Output is correct
15 Correct 19 ms 320 KB Output is correct
16 Correct 19 ms 212 KB Output is correct
17 Correct 24 ms 212 KB Output is correct
18 Correct 18 ms 308 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 21 ms 304 KB Output is correct
21 Correct 18 ms 316 KB Output is correct
22 Correct 18 ms 308 KB Output is correct
23 Correct 18 ms 316 KB Output is correct
24 Correct 18 ms 320 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Execution timed out 1079 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 212 KB Output is correct
2 Correct 23 ms 320 KB Output is correct
3 Correct 18 ms 296 KB Output is correct
4 Correct 18 ms 300 KB Output is correct
5 Correct 19 ms 212 KB Output is correct
6 Correct 19 ms 212 KB Output is correct
7 Correct 20 ms 324 KB Output is correct
8 Correct 18 ms 316 KB Output is correct
9 Correct 17 ms 212 KB Output is correct
10 Correct 20 ms 316 KB Output is correct
11 Correct 19 ms 212 KB Output is correct
12 Correct 21 ms 212 KB Output is correct
13 Correct 19 ms 212 KB Output is correct
14 Correct 19 ms 316 KB Output is correct
15 Correct 19 ms 320 KB Output is correct
16 Correct 19 ms 212 KB Output is correct
17 Correct 24 ms 212 KB Output is correct
18 Correct 18 ms 308 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 21 ms 304 KB Output is correct
21 Correct 18 ms 316 KB Output is correct
22 Correct 18 ms 308 KB Output is correct
23 Correct 18 ms 316 KB Output is correct
24 Correct 18 ms 320 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Execution timed out 1079 ms 212 KB Time limit exceeded
30 Halted 0 ms 0 KB -