Submission #943379

# Submission time Handle Problem Language Result Execution time Memory
943379 2024-03-11T12:29:45 Z Ahmed57 Homework (CEOI22_homework) C++17
53 / 100
122 ms 171904 KB
#include "bits/stdc++.h"

using namespace std;
#define int long long
#ifdef LOCAL
#include "debug.cpp"
#else
#define debug(...)
#endif
int NODES = 0;
string s;
int L[1000001],R[1000001],nah[1000001];
int pref[1000001];
vector<int> v[1000001];
int query(int l,int r){
    return pref[r]-(l==0?0:pref[l-1]);
}
int rec(int l,int r){
    if(l==r){
        return nah[l];
    }
    NODES++;
    int p1 = rec(l+4,v[l][1]-2);
    int p2 = rec(v[l][1],r-1);
    int l1 = l+4 , r1 = v[l][1]-2;
    int l2 = v[l][1] , r2 = r-1;
    if(s[l+2]=='x'){
        R[NODES] = query(l,r)-min(query(l1,r1)-R[p1],query(l2,r2)-R[p2]);
        L[NODES] = query(l,r)-(query(l1,r1)-L[p1])-(query(l2,r2)-L[p2]);
    }else {
        L[NODES] = min(L[p1],L[p2]);
        R[NODES] = R[p1]+R[p2]-1;
    }
    return NODES;
}
signed main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    int i = 0;
    stack<int> st;
    while(i<s.size()){
        if(s[i]=='m'){
            if(!st.empty()){
                v[st.top()].push_back(i);
            }
            st.push(i);
            i+=4;
        }if(s[i]=='?'){
            if(!st.empty()){
                v[st.top()].push_back(i);
            }
            i++;
        }if(s[i]==')'){
            st.pop();
            i++;
        }if(s[i]==',')i++;
    }
    for(int i = 0;i<s.size();i++){
        if(s[i]=='?'){
            pref[i] = 1;
            L[NODES] = 1;
            R[NODES] = 1;
            nah[i] = NODES;
            NODES++;
        }
        if(i)pref[i]+=pref[i-1];
    }
    int nah = rec(0,s.size()-1);
    cout<<R[nah]-L[nah]+1<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:41:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     while(i<s.size()){
      |           ~^~~~~~~~~
Main.cpp:58:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i = 0;i<s.size();i++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 6 ms 31324 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 7 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31324 KB Output is correct
13 Correct 7 ms 31580 KB Output is correct
14 Correct 6 ms 31320 KB Output is correct
15 Correct 7 ms 31400 KB Output is correct
16 Correct 6 ms 31352 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 7 ms 31364 KB Output is correct
19 Correct 6 ms 31324 KB Output is correct
20 Correct 6 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 6 ms 31324 KB Output is correct
23 Correct 6 ms 31324 KB Output is correct
24 Correct 7 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31324 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 6 ms 31324 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 7 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31324 KB Output is correct
13 Correct 7 ms 31580 KB Output is correct
14 Correct 6 ms 31320 KB Output is correct
15 Correct 7 ms 31400 KB Output is correct
16 Correct 6 ms 31352 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 7 ms 31364 KB Output is correct
19 Correct 6 ms 31324 KB Output is correct
20 Correct 6 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 6 ms 31324 KB Output is correct
23 Correct 6 ms 31324 KB Output is correct
24 Correct 7 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31324 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 6 ms 31320 KB Output is correct
30 Correct 6 ms 31320 KB Output is correct
31 Correct 6 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31324 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 7 ms 31324 KB Output is correct
36 Correct 7 ms 31320 KB Output is correct
37 Correct 6 ms 31324 KB Output is correct
38 Correct 6 ms 31324 KB Output is correct
39 Correct 7 ms 31576 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 6 ms 31324 KB Output is correct
42 Correct 6 ms 31408 KB Output is correct
43 Correct 6 ms 31412 KB Output is correct
44 Correct 6 ms 31408 KB Output is correct
45 Correct 6 ms 31324 KB Output is correct
46 Correct 7 ms 31324 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 6 ms 31576 KB Output is correct
49 Correct 6 ms 31324 KB Output is correct
50 Correct 7 ms 31324 KB Output is correct
51 Correct 7 ms 31324 KB Output is correct
52 Correct 7 ms 31324 KB Output is correct
53 Correct 6 ms 31320 KB Output is correct
54 Correct 6 ms 31324 KB Output is correct
55 Correct 6 ms 31400 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 122 ms 171904 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 6 ms 31324 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 7 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31324 KB Output is correct
13 Correct 7 ms 31580 KB Output is correct
14 Correct 6 ms 31320 KB Output is correct
15 Correct 7 ms 31400 KB Output is correct
16 Correct 6 ms 31352 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 7 ms 31364 KB Output is correct
19 Correct 6 ms 31324 KB Output is correct
20 Correct 6 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 6 ms 31324 KB Output is correct
23 Correct 6 ms 31324 KB Output is correct
24 Correct 7 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31324 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 6 ms 31320 KB Output is correct
30 Correct 6 ms 31320 KB Output is correct
31 Correct 6 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31324 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 7 ms 31324 KB Output is correct
36 Correct 7 ms 31320 KB Output is correct
37 Correct 6 ms 31324 KB Output is correct
38 Correct 6 ms 31324 KB Output is correct
39 Correct 7 ms 31576 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 6 ms 31324 KB Output is correct
42 Correct 6 ms 31408 KB Output is correct
43 Correct 6 ms 31412 KB Output is correct
44 Correct 6 ms 31408 KB Output is correct
45 Correct 6 ms 31324 KB Output is correct
46 Correct 7 ms 31324 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 6 ms 31576 KB Output is correct
49 Correct 6 ms 31324 KB Output is correct
50 Correct 7 ms 31324 KB Output is correct
51 Correct 7 ms 31324 KB Output is correct
52 Correct 7 ms 31324 KB Output is correct
53 Correct 6 ms 31320 KB Output is correct
54 Correct 6 ms 31324 KB Output is correct
55 Correct 6 ms 31400 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
57 Correct 6 ms 31320 KB Output is correct
58 Correct 6 ms 31324 KB Output is correct
59 Correct 6 ms 31324 KB Output is correct
60 Correct 6 ms 31324 KB Output is correct
61 Correct 7 ms 31324 KB Output is correct
62 Correct 7 ms 31324 KB Output is correct
63 Correct 7 ms 31324 KB Output is correct
64 Correct 7 ms 31320 KB Output is correct
65 Correct 6 ms 31324 KB Output is correct
66 Correct 7 ms 31356 KB Output is correct
67 Correct 6 ms 31324 KB Output is correct
68 Correct 8 ms 31664 KB Output is correct
69 Correct 7 ms 31316 KB Output is correct
70 Correct 6 ms 31320 KB Output is correct
71 Correct 6 ms 31324 KB Output is correct
72 Correct 6 ms 31324 KB Output is correct
73 Correct 7 ms 31324 KB Output is correct
74 Correct 6 ms 31324 KB Output is correct
75 Correct 7 ms 31356 KB Output is correct
76 Correct 7 ms 31320 KB Output is correct
77 Correct 7 ms 31356 KB Output is correct
78 Correct 6 ms 31324 KB Output is correct
79 Correct 6 ms 31324 KB Output is correct
80 Correct 7 ms 31320 KB Output is correct
81 Correct 7 ms 31324 KB Output is correct
82 Correct 7 ms 31324 KB Output is correct
83 Correct 6 ms 31324 KB Output is correct
84 Correct 7 ms 31324 KB Output is correct
85 Correct 7 ms 31324 KB Output is correct
86 Correct 6 ms 31320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 6 ms 31324 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 7 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31324 KB Output is correct
13 Correct 7 ms 31580 KB Output is correct
14 Correct 6 ms 31320 KB Output is correct
15 Correct 7 ms 31400 KB Output is correct
16 Correct 6 ms 31352 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 7 ms 31364 KB Output is correct
19 Correct 6 ms 31324 KB Output is correct
20 Correct 6 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 6 ms 31324 KB Output is correct
23 Correct 6 ms 31324 KB Output is correct
24 Correct 7 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31324 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 6 ms 31320 KB Output is correct
30 Correct 6 ms 31320 KB Output is correct
31 Correct 6 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31324 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 7 ms 31324 KB Output is correct
36 Correct 7 ms 31320 KB Output is correct
37 Correct 6 ms 31324 KB Output is correct
38 Correct 6 ms 31324 KB Output is correct
39 Correct 7 ms 31576 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 6 ms 31324 KB Output is correct
42 Correct 6 ms 31408 KB Output is correct
43 Correct 6 ms 31412 KB Output is correct
44 Correct 6 ms 31408 KB Output is correct
45 Correct 6 ms 31324 KB Output is correct
46 Correct 7 ms 31324 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 6 ms 31576 KB Output is correct
49 Correct 6 ms 31324 KB Output is correct
50 Correct 7 ms 31324 KB Output is correct
51 Correct 7 ms 31324 KB Output is correct
52 Correct 7 ms 31324 KB Output is correct
53 Correct 6 ms 31320 KB Output is correct
54 Correct 6 ms 31324 KB Output is correct
55 Correct 6 ms 31400 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
57 Runtime error 122 ms 171904 KB Execution killed with signal 11
58 Halted 0 ms 0 KB -