Submission #619876

# Submission time Handle Problem Language Result Execution time Memory
619876 2022-08-02T16:46:28 Z APROHACK Crossing (JOI21_crossing) C++14
3 / 100
273 ms 24256 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
string a, b, c, x;
ll n, q;
struct crossing
{
    int dd, ht, mid;
    char toProp;
    bool faltaprop;
    bool allJ, allO, allI, iscorrect;
    crossing *L, *R;
    crossing(){}
    crossing(int l, int r){
        dd = l, ht = r;
        mid = (dd+ht)/2;
        if(l!=r){
            L = new crossing(l, mid);
            R = new crossing(mid+1, r);
            allJ = L->allJ && R->allJ;
            allO = L->allO && R->allO;
            allI = L->allI && R->allI;
            iscorrect = L->iscorrect && R->iscorrect;
        }else{
            allJ = a[dd] == 'J';
            allO = a[dd] == 'O';
            allI = a[dd] == 'I';
            if(a[dd]==x[dd])iscorrect = true;
        }
    }
    void propagate(){
        if(!faltaprop)return;
        L->insert(dd, mid, toProp);
        R->insert(mid+1, ht, toProp);
        iscorrect = L->iscorrect && R->iscorrect;
        faltaprop=false;
    }
    void insert(int l, int r, char cual){
        if(dd == l && r==ht ){
            if(cual == 'J' && allJ)iscorrect = true;
            else if(cual == 'O'&&allO)iscorrect=true;
            else if(cual == 'I' && allI)iscorrect = true;
            else iscorrect=false;
            //no hace falta propagar lo que hay aca
            toProp = cual;
            faltaprop = true;
            return ;
        }
        propagate();
        if(r<=mid)L->insert(l, r, cual);
        else if(mid<l)R->insert(l, r, cual);
        else {
            L->insert(l, mid, cual);
            R->insert(mid+1, r, cual);
        }
        iscorrect = L->iscorrect && R->iscorrect;
    }

};
crossing *seg;
void input(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin>>n;
    cin>>a>>b>>c;
    cin>>q;
    cin>>x;
}
bool askforX(){
    seg = new crossing(0, n-1);
    return seg->iscorrect;
}
int main(){
    input();
    if(askforX())cout << "Yes\n";
    else cout << "No\n";
    ll l, r;
    char value;
    for(int i = 0 ; i < q ; i++){
        cin>>l>>r>>value;
        seg->insert(l-1, r-1, value);
        if(seg->iscorrect)cout<<"Yes\n";
        else cout << "No\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 61 ms 844 KB Output is correct
2 Correct 66 ms 852 KB Output is correct
3 Correct 60 ms 880 KB Output is correct
4 Correct 52 ms 856 KB Output is correct
5 Correct 53 ms 1148 KB Output is correct
6 Correct 55 ms 1072 KB Output is correct
7 Correct 62 ms 1096 KB Output is correct
8 Correct 58 ms 1180 KB Output is correct
9 Correct 59 ms 1048 KB Output is correct
10 Correct 57 ms 1084 KB Output is correct
11 Correct 59 ms 1128 KB Output is correct
12 Correct 61 ms 1128 KB Output is correct
13 Correct 58 ms 1056 KB Output is correct
14 Correct 59 ms 1056 KB Output is correct
15 Correct 59 ms 1072 KB Output is correct
16 Correct 62 ms 1120 KB Output is correct
17 Correct 58 ms 1104 KB Output is correct
18 Correct 62 ms 1092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 844 KB Output is correct
2 Correct 66 ms 852 KB Output is correct
3 Correct 60 ms 880 KB Output is correct
4 Correct 52 ms 856 KB Output is correct
5 Correct 53 ms 1148 KB Output is correct
6 Correct 55 ms 1072 KB Output is correct
7 Correct 62 ms 1096 KB Output is correct
8 Correct 58 ms 1180 KB Output is correct
9 Correct 59 ms 1048 KB Output is correct
10 Correct 57 ms 1084 KB Output is correct
11 Correct 59 ms 1128 KB Output is correct
12 Correct 61 ms 1128 KB Output is correct
13 Correct 58 ms 1056 KB Output is correct
14 Correct 59 ms 1056 KB Output is correct
15 Correct 59 ms 1072 KB Output is correct
16 Correct 62 ms 1120 KB Output is correct
17 Correct 58 ms 1104 KB Output is correct
18 Correct 62 ms 1092 KB Output is correct
19 Correct 273 ms 21424 KB Output is correct
20 Correct 204 ms 24116 KB Output is correct
21 Correct 180 ms 22704 KB Output is correct
22 Correct 160 ms 20648 KB Output is correct
23 Correct 86 ms 4252 KB Output is correct
24 Correct 86 ms 4172 KB Output is correct
25 Correct 181 ms 24256 KB Output is correct
26 Correct 187 ms 24176 KB Output is correct
27 Correct 196 ms 24160 KB Output is correct
28 Correct 246 ms 24152 KB Output is correct
29 Correct 187 ms 23464 KB Output is correct
30 Correct 99 ms 4224 KB Output is correct
31 Correct 204 ms 24172 KB Output is correct
32 Correct 205 ms 22244 KB Output is correct
33 Correct 96 ms 4164 KB Output is correct
34 Correct 236 ms 24104 KB Output is correct
35 Correct 161 ms 18592 KB Output is correct
36 Correct 90 ms 4196 KB Output is correct
37 Correct 88 ms 4208 KB Output is correct
38 Correct 185 ms 23940 KB Output is correct
39 Incorrect 97 ms 24228 KB Output isn't correct
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 844 KB Output is correct
2 Correct 66 ms 852 KB Output is correct
3 Correct 60 ms 880 KB Output is correct
4 Correct 52 ms 856 KB Output is correct
5 Correct 53 ms 1148 KB Output is correct
6 Correct 55 ms 1072 KB Output is correct
7 Correct 62 ms 1096 KB Output is correct
8 Correct 58 ms 1180 KB Output is correct
9 Correct 59 ms 1048 KB Output is correct
10 Correct 57 ms 1084 KB Output is correct
11 Correct 59 ms 1128 KB Output is correct
12 Correct 61 ms 1128 KB Output is correct
13 Correct 58 ms 1056 KB Output is correct
14 Correct 59 ms 1056 KB Output is correct
15 Correct 59 ms 1072 KB Output is correct
16 Correct 62 ms 1120 KB Output is correct
17 Correct 58 ms 1104 KB Output is correct
18 Correct 62 ms 1092 KB Output is correct
19 Correct 68 ms 1092 KB Output is correct
20 Correct 62 ms 1156 KB Output is correct
21 Incorrect 62 ms 1100 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 844 KB Output is correct
2 Correct 66 ms 852 KB Output is correct
3 Correct 60 ms 880 KB Output is correct
4 Correct 52 ms 856 KB Output is correct
5 Correct 53 ms 1148 KB Output is correct
6 Correct 55 ms 1072 KB Output is correct
7 Correct 62 ms 1096 KB Output is correct
8 Correct 58 ms 1180 KB Output is correct
9 Correct 59 ms 1048 KB Output is correct
10 Correct 57 ms 1084 KB Output is correct
11 Correct 59 ms 1128 KB Output is correct
12 Correct 61 ms 1128 KB Output is correct
13 Correct 58 ms 1056 KB Output is correct
14 Correct 59 ms 1056 KB Output is correct
15 Correct 59 ms 1072 KB Output is correct
16 Correct 62 ms 1120 KB Output is correct
17 Correct 58 ms 1104 KB Output is correct
18 Correct 62 ms 1092 KB Output is correct
19 Correct 273 ms 21424 KB Output is correct
20 Correct 204 ms 24116 KB Output is correct
21 Correct 180 ms 22704 KB Output is correct
22 Correct 160 ms 20648 KB Output is correct
23 Correct 86 ms 4252 KB Output is correct
24 Correct 86 ms 4172 KB Output is correct
25 Correct 181 ms 24256 KB Output is correct
26 Correct 187 ms 24176 KB Output is correct
27 Correct 196 ms 24160 KB Output is correct
28 Correct 246 ms 24152 KB Output is correct
29 Correct 187 ms 23464 KB Output is correct
30 Correct 99 ms 4224 KB Output is correct
31 Correct 204 ms 24172 KB Output is correct
32 Correct 205 ms 22244 KB Output is correct
33 Correct 96 ms 4164 KB Output is correct
34 Correct 236 ms 24104 KB Output is correct
35 Correct 161 ms 18592 KB Output is correct
36 Correct 90 ms 4196 KB Output is correct
37 Correct 88 ms 4208 KB Output is correct
38 Correct 185 ms 23940 KB Output is correct
39 Incorrect 97 ms 24228 KB Output isn't correct
40 Halted 0 ms 0 KB -