답안 #705458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705458 2023-03-04T12:37:31 Z krizsu222 Homework (CEOI22_homework) C++17
10 / 100
1000 ms 187844 KB
#include "bits/stdc++.h"
#define ls (v * 2)
#define rs (v * 2 + 1)
#define TREE_SIZE (1<<20)
using namespace std;

struct node
{
    string type;
    int value;
} tree[TREE_SIZE * 2];
string s;
int res;
int const maxn = 1e6 + 3;
bool ok[maxn];

void insert(int v, int val)
{
    //v += TREE_SIZE;
    tree[v].value = val;
    while(v != 0)
    {
        v /= 2;     
        if(tree[v].type == "min")
        {
            if(tree[rs].value == 0) tree[v].value = tree[ls].value;
            else tree[v].value = min(tree[ls].value, tree[rs].value);
        }
        if(tree[v].type == "max")
        {
            if(tree[rs].value == 0) tree[v].value = tree[ls].value;
            else tree[v].value = max(tree[ls].value, tree[rs].value);
        }
    }
}

signed main()
{
    cin.tie(0) -> ios_base::sync_with_stdio(0);
    cout.tie(0) -> ios_base::sync_with_stdio(0);

    cin >> s;
    int question_marks = 0;
    for(auto u : s)
        if(u == '?')
            question_marks++;
    vector <int> q;
    string temp = "";
    int it = 1, son = 0, lastfunc = 0;
    for(int i = 0; i < s.length(); ++i)
    {
        if(s[i] == 'm' || s[i] == 'i' || s[i] == 'a') continue;
        if(s[i] == '(') it *= 2;
        if(s[i] == ')') it /= 2;
        it += son;
        int act_son = it;
        if(s[i] == ',') son = 1;
        else son = 0;
        if(s[i] == 'n')
            tree[act_son].type = "min";
        if(s[i] == 'x')
            tree[act_son].type = "max";
        if(s[i] == '?')
        {
            tree[act_son].type = "const";
            q.push_back(act_son);
        }
    }
    // for(auto u : q)
    //     cout << u << ' ';
    vector <int> perms(question_marks);
    for(int i = 0; i < question_marks; ++i)
        perms[i] = i + 1;
    do
    {
        for(int i = 0; i < question_marks; ++i)
            insert(q[i], perms[i]);
        ok[tree[1].value] = true; 
        //cout << tree[1].value << '\n';
    } while(next_permutation(perms.begin(), perms.end()));
    for(int i = 1; i <= question_marks; ++i)
        if(ok[i] == true)
            res++;
    cout << res;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < s.length(); ++i)
      |                    ~~^~~~~~~~~~~~
Main.cpp:49:26: warning: unused variable 'lastfunc' [-Wunused-variable]
   49 |     int it = 1, son = 0, lastfunc = 0;
      |                          ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 82388 KB Output is correct
2 Correct 363 ms 82388 KB Output is correct
3 Correct 384 ms 82392 KB Output is correct
4 Correct 382 ms 82392 KB Output is correct
5 Correct 425 ms 82392 KB Output is correct
6 Correct 410 ms 82388 KB Output is correct
7 Correct 423 ms 82384 KB Output is correct
8 Correct 428 ms 82388 KB Output is correct
9 Correct 396 ms 82384 KB Output is correct
10 Correct 419 ms 82384 KB Output is correct
11 Correct 498 ms 82388 KB Output is correct
12 Correct 408 ms 82392 KB Output is correct
13 Correct 381 ms 82388 KB Output is correct
14 Correct 397 ms 82500 KB Output is correct
15 Correct 466 ms 82384 KB Output is correct
16 Correct 583 ms 82388 KB Output is correct
17 Correct 552 ms 82388 KB Output is correct
18 Correct 479 ms 82392 KB Output is correct
19 Correct 485 ms 82388 KB Output is correct
20 Correct 476 ms 82384 KB Output is correct
21 Correct 414 ms 82288 KB Output is correct
22 Correct 400 ms 82384 KB Output is correct
23 Correct 436 ms 82384 KB Output is correct
24 Correct 552 ms 82392 KB Output is correct
25 Correct 88 ms 82384 KB Output is correct
26 Correct 70 ms 82388 KB Output is correct
27 Correct 73 ms 82388 KB Output is correct
28 Correct 53 ms 82392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 82388 KB Output is correct
2 Correct 363 ms 82388 KB Output is correct
3 Correct 384 ms 82392 KB Output is correct
4 Correct 382 ms 82392 KB Output is correct
5 Correct 425 ms 82392 KB Output is correct
6 Correct 410 ms 82388 KB Output is correct
7 Correct 423 ms 82384 KB Output is correct
8 Correct 428 ms 82388 KB Output is correct
9 Correct 396 ms 82384 KB Output is correct
10 Correct 419 ms 82384 KB Output is correct
11 Correct 498 ms 82388 KB Output is correct
12 Correct 408 ms 82392 KB Output is correct
13 Correct 381 ms 82388 KB Output is correct
14 Correct 397 ms 82500 KB Output is correct
15 Correct 466 ms 82384 KB Output is correct
16 Correct 583 ms 82388 KB Output is correct
17 Correct 552 ms 82388 KB Output is correct
18 Correct 479 ms 82392 KB Output is correct
19 Correct 485 ms 82388 KB Output is correct
20 Correct 476 ms 82384 KB Output is correct
21 Correct 414 ms 82288 KB Output is correct
22 Correct 400 ms 82384 KB Output is correct
23 Correct 436 ms 82384 KB Output is correct
24 Correct 552 ms 82392 KB Output is correct
25 Correct 88 ms 82384 KB Output is correct
26 Correct 70 ms 82388 KB Output is correct
27 Correct 73 ms 82388 KB Output is correct
28 Correct 53 ms 82392 KB Output is correct
29 Execution timed out 1063 ms 82304 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 145 ms 187844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 82388 KB Output is correct
2 Correct 363 ms 82388 KB Output is correct
3 Correct 384 ms 82392 KB Output is correct
4 Correct 382 ms 82392 KB Output is correct
5 Correct 425 ms 82392 KB Output is correct
6 Correct 410 ms 82388 KB Output is correct
7 Correct 423 ms 82384 KB Output is correct
8 Correct 428 ms 82388 KB Output is correct
9 Correct 396 ms 82384 KB Output is correct
10 Correct 419 ms 82384 KB Output is correct
11 Correct 498 ms 82388 KB Output is correct
12 Correct 408 ms 82392 KB Output is correct
13 Correct 381 ms 82388 KB Output is correct
14 Correct 397 ms 82500 KB Output is correct
15 Correct 466 ms 82384 KB Output is correct
16 Correct 583 ms 82388 KB Output is correct
17 Correct 552 ms 82388 KB Output is correct
18 Correct 479 ms 82392 KB Output is correct
19 Correct 485 ms 82388 KB Output is correct
20 Correct 476 ms 82384 KB Output is correct
21 Correct 414 ms 82288 KB Output is correct
22 Correct 400 ms 82384 KB Output is correct
23 Correct 436 ms 82384 KB Output is correct
24 Correct 552 ms 82392 KB Output is correct
25 Correct 88 ms 82384 KB Output is correct
26 Correct 70 ms 82388 KB Output is correct
27 Correct 73 ms 82388 KB Output is correct
28 Correct 53 ms 82392 KB Output is correct
29 Execution timed out 1063 ms 82304 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 82388 KB Output is correct
2 Correct 363 ms 82388 KB Output is correct
3 Correct 384 ms 82392 KB Output is correct
4 Correct 382 ms 82392 KB Output is correct
5 Correct 425 ms 82392 KB Output is correct
6 Correct 410 ms 82388 KB Output is correct
7 Correct 423 ms 82384 KB Output is correct
8 Correct 428 ms 82388 KB Output is correct
9 Correct 396 ms 82384 KB Output is correct
10 Correct 419 ms 82384 KB Output is correct
11 Correct 498 ms 82388 KB Output is correct
12 Correct 408 ms 82392 KB Output is correct
13 Correct 381 ms 82388 KB Output is correct
14 Correct 397 ms 82500 KB Output is correct
15 Correct 466 ms 82384 KB Output is correct
16 Correct 583 ms 82388 KB Output is correct
17 Correct 552 ms 82388 KB Output is correct
18 Correct 479 ms 82392 KB Output is correct
19 Correct 485 ms 82388 KB Output is correct
20 Correct 476 ms 82384 KB Output is correct
21 Correct 414 ms 82288 KB Output is correct
22 Correct 400 ms 82384 KB Output is correct
23 Correct 436 ms 82384 KB Output is correct
24 Correct 552 ms 82392 KB Output is correct
25 Correct 88 ms 82384 KB Output is correct
26 Correct 70 ms 82388 KB Output is correct
27 Correct 73 ms 82388 KB Output is correct
28 Correct 53 ms 82392 KB Output is correct
29 Execution timed out 1063 ms 82304 KB Time limit exceeded
30 Halted 0 ms 0 KB -