Submission #620028

# Submission time Handle Problem Language Result Execution time Memory
620028 2022-08-02T19:11:11 Z APROHACK Crossing (JOI21_crossing) C++14
26 / 100
607 ms 24452 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){
       // cout << dd << " " << ht << " " << l << " " << r << endl;
        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" << endl;
    else cout << "No" << endl;
    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" << endl;
        else cout << "No" << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 306 ms 832 KB Output is correct
2 Correct 338 ms 980 KB Output is correct
3 Correct 335 ms 992 KB Output is correct
4 Correct 324 ms 1000 KB Output is correct
5 Correct 320 ms 936 KB Output is correct
6 Correct 318 ms 928 KB Output is correct
7 Correct 336 ms 960 KB Output is correct
8 Correct 338 ms 980 KB Output is correct
9 Correct 336 ms 984 KB Output is correct
10 Correct 337 ms 988 KB Output is correct
11 Correct 330 ms 932 KB Output is correct
12 Correct 332 ms 988 KB Output is correct
13 Correct 337 ms 1060 KB Output is correct
14 Correct 333 ms 1048 KB Output is correct
15 Correct 329 ms 968 KB Output is correct
16 Correct 326 ms 960 KB Output is correct
17 Correct 336 ms 972 KB Output is correct
18 Correct 332 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 832 KB Output is correct
2 Correct 338 ms 980 KB Output is correct
3 Correct 335 ms 992 KB Output is correct
4 Correct 324 ms 1000 KB Output is correct
5 Correct 320 ms 936 KB Output is correct
6 Correct 318 ms 928 KB Output is correct
7 Correct 336 ms 960 KB Output is correct
8 Correct 338 ms 980 KB Output is correct
9 Correct 336 ms 984 KB Output is correct
10 Correct 337 ms 988 KB Output is correct
11 Correct 330 ms 932 KB Output is correct
12 Correct 332 ms 988 KB Output is correct
13 Correct 337 ms 1060 KB Output is correct
14 Correct 333 ms 1048 KB Output is correct
15 Correct 329 ms 968 KB Output is correct
16 Correct 326 ms 960 KB Output is correct
17 Correct 336 ms 972 KB Output is correct
18 Correct 332 ms 1048 KB Output is correct
19 Correct 576 ms 21344 KB Output is correct
20 Correct 530 ms 24004 KB Output is correct
21 Correct 472 ms 22736 KB Output is correct
22 Correct 473 ms 20668 KB Output is correct
23 Correct 396 ms 4300 KB Output is correct
24 Correct 384 ms 4240 KB Output is correct
25 Correct 506 ms 24160 KB Output is correct
26 Correct 511 ms 24076 KB Output is correct
27 Correct 518 ms 24076 KB Output is correct
28 Correct 551 ms 24244 KB Output is correct
29 Correct 508 ms 23528 KB Output is correct
30 Correct 400 ms 4304 KB Output is correct
31 Correct 516 ms 24032 KB Output is correct
32 Correct 506 ms 22104 KB Output is correct
33 Correct 388 ms 4172 KB Output is correct
34 Correct 540 ms 24296 KB Output is correct
35 Correct 447 ms 18652 KB Output is correct
36 Correct 394 ms 4132 KB Output is correct
37 Correct 387 ms 4156 KB Output is correct
38 Correct 506 ms 23900 KB Output is correct
39 Correct 422 ms 24080 KB Output is correct
40 Correct 470 ms 17188 KB Output is correct
41 Correct 607 ms 24452 KB Output is correct
42 Correct 360 ms 23564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 832 KB Output is correct
2 Correct 338 ms 980 KB Output is correct
3 Correct 335 ms 992 KB Output is correct
4 Correct 324 ms 1000 KB Output is correct
5 Correct 320 ms 936 KB Output is correct
6 Correct 318 ms 928 KB Output is correct
7 Correct 336 ms 960 KB Output is correct
8 Correct 338 ms 980 KB Output is correct
9 Correct 336 ms 984 KB Output is correct
10 Correct 337 ms 988 KB Output is correct
11 Correct 330 ms 932 KB Output is correct
12 Correct 332 ms 988 KB Output is correct
13 Correct 337 ms 1060 KB Output is correct
14 Correct 333 ms 1048 KB Output is correct
15 Correct 329 ms 968 KB Output is correct
16 Correct 326 ms 960 KB Output is correct
17 Correct 336 ms 972 KB Output is correct
18 Correct 332 ms 1048 KB Output is correct
19 Correct 330 ms 940 KB Output is correct
20 Correct 335 ms 980 KB Output is correct
21 Incorrect 350 ms 904 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 832 KB Output is correct
2 Correct 338 ms 980 KB Output is correct
3 Correct 335 ms 992 KB Output is correct
4 Correct 324 ms 1000 KB Output is correct
5 Correct 320 ms 936 KB Output is correct
6 Correct 318 ms 928 KB Output is correct
7 Correct 336 ms 960 KB Output is correct
8 Correct 338 ms 980 KB Output is correct
9 Correct 336 ms 984 KB Output is correct
10 Correct 337 ms 988 KB Output is correct
11 Correct 330 ms 932 KB Output is correct
12 Correct 332 ms 988 KB Output is correct
13 Correct 337 ms 1060 KB Output is correct
14 Correct 333 ms 1048 KB Output is correct
15 Correct 329 ms 968 KB Output is correct
16 Correct 326 ms 960 KB Output is correct
17 Correct 336 ms 972 KB Output is correct
18 Correct 332 ms 1048 KB Output is correct
19 Correct 576 ms 21344 KB Output is correct
20 Correct 530 ms 24004 KB Output is correct
21 Correct 472 ms 22736 KB Output is correct
22 Correct 473 ms 20668 KB Output is correct
23 Correct 396 ms 4300 KB Output is correct
24 Correct 384 ms 4240 KB Output is correct
25 Correct 506 ms 24160 KB Output is correct
26 Correct 511 ms 24076 KB Output is correct
27 Correct 518 ms 24076 KB Output is correct
28 Correct 551 ms 24244 KB Output is correct
29 Correct 508 ms 23528 KB Output is correct
30 Correct 400 ms 4304 KB Output is correct
31 Correct 516 ms 24032 KB Output is correct
32 Correct 506 ms 22104 KB Output is correct
33 Correct 388 ms 4172 KB Output is correct
34 Correct 540 ms 24296 KB Output is correct
35 Correct 447 ms 18652 KB Output is correct
36 Correct 394 ms 4132 KB Output is correct
37 Correct 387 ms 4156 KB Output is correct
38 Correct 506 ms 23900 KB Output is correct
39 Correct 422 ms 24080 KB Output is correct
40 Correct 470 ms 17188 KB Output is correct
41 Correct 607 ms 24452 KB Output is correct
42 Correct 360 ms 23564 KB Output is correct
43 Correct 330 ms 940 KB Output is correct
44 Correct 335 ms 980 KB Output is correct
45 Incorrect 350 ms 904 KB Output isn't correct
46 Halted 0 ms 0 KB -