Submission #619889

# Submission time Handle Problem Language Result Execution time Memory
619889 2022-08-02T16:52:05 Z APROHACK Crossing (JOI21_crossing) C++14
3 / 100
7000 ms 26292 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
{
    ll 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!=ht)propagate();
        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 ;
        }
        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 122 ms 844 KB Output is correct
2 Correct 171 ms 880 KB Output is correct
3 Correct 423 ms 868 KB Output is correct
4 Correct 129 ms 840 KB Output is correct
5 Correct 102 ms 852 KB Output is correct
6 Correct 112 ms 852 KB Output is correct
7 Correct 116 ms 880 KB Output is correct
8 Correct 127 ms 828 KB Output is correct
9 Correct 106 ms 908 KB Output is correct
10 Correct 130 ms 916 KB Output is correct
11 Correct 112 ms 848 KB Output is correct
12 Correct 105 ms 888 KB Output is correct
13 Correct 125 ms 828 KB Output is correct
14 Correct 114 ms 884 KB Output is correct
15 Correct 111 ms 796 KB Output is correct
16 Correct 119 ms 796 KB Output is correct
17 Correct 110 ms 884 KB Output is correct
18 Correct 313 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 844 KB Output is correct
2 Correct 171 ms 880 KB Output is correct
3 Correct 423 ms 868 KB Output is correct
4 Correct 129 ms 840 KB Output is correct
5 Correct 102 ms 852 KB Output is correct
6 Correct 112 ms 852 KB Output is correct
7 Correct 116 ms 880 KB Output is correct
8 Correct 127 ms 828 KB Output is correct
9 Correct 106 ms 908 KB Output is correct
10 Correct 130 ms 916 KB Output is correct
11 Correct 112 ms 848 KB Output is correct
12 Correct 105 ms 888 KB Output is correct
13 Correct 125 ms 828 KB Output is correct
14 Correct 114 ms 884 KB Output is correct
15 Correct 111 ms 796 KB Output is correct
16 Correct 119 ms 796 KB Output is correct
17 Correct 110 ms 884 KB Output is correct
18 Correct 313 ms 856 KB Output is correct
19 Execution timed out 7065 ms 26292 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 844 KB Output is correct
2 Correct 171 ms 880 KB Output is correct
3 Correct 423 ms 868 KB Output is correct
4 Correct 129 ms 840 KB Output is correct
5 Correct 102 ms 852 KB Output is correct
6 Correct 112 ms 852 KB Output is correct
7 Correct 116 ms 880 KB Output is correct
8 Correct 127 ms 828 KB Output is correct
9 Correct 106 ms 908 KB Output is correct
10 Correct 130 ms 916 KB Output is correct
11 Correct 112 ms 848 KB Output is correct
12 Correct 105 ms 888 KB Output is correct
13 Correct 125 ms 828 KB Output is correct
14 Correct 114 ms 884 KB Output is correct
15 Correct 111 ms 796 KB Output is correct
16 Correct 119 ms 796 KB Output is correct
17 Correct 110 ms 884 KB Output is correct
18 Correct 313 ms 856 KB Output is correct
19 Correct 157 ms 1100 KB Output is correct
20 Correct 414 ms 1168 KB Output is correct
21 Incorrect 115 ms 1116 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 844 KB Output is correct
2 Correct 171 ms 880 KB Output is correct
3 Correct 423 ms 868 KB Output is correct
4 Correct 129 ms 840 KB Output is correct
5 Correct 102 ms 852 KB Output is correct
6 Correct 112 ms 852 KB Output is correct
7 Correct 116 ms 880 KB Output is correct
8 Correct 127 ms 828 KB Output is correct
9 Correct 106 ms 908 KB Output is correct
10 Correct 130 ms 916 KB Output is correct
11 Correct 112 ms 848 KB Output is correct
12 Correct 105 ms 888 KB Output is correct
13 Correct 125 ms 828 KB Output is correct
14 Correct 114 ms 884 KB Output is correct
15 Correct 111 ms 796 KB Output is correct
16 Correct 119 ms 796 KB Output is correct
17 Correct 110 ms 884 KB Output is correct
18 Correct 313 ms 856 KB Output is correct
19 Execution timed out 7065 ms 26292 KB Time limit exceeded
20 Halted 0 ms 0 KB -