Submission #711054

# Submission time Handle Problem Language Result Execution time Memory
711054 2023-03-16T07:46:55 Z zeta7532 Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 13976 KB
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
using namespace std;    
using ll = int;
const ll mod = 998244353;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,x) for(ll i=0;i<x;i++)
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
     
int main(){
    ll N;
    cin >> N;
    vector<ll> rui(N);
    rui[0]=1;
    rep(i,N-1) rui[i+1]=(rui[i]*3)%mod;
    vector<vector<ll>> S(N,vector<ll>(3));
    rep(i,3){
        rep(j,N){
            char c;
            cin >> c;
            if(c=='J') S[j][i]=0;
            if(c=='O') S[j][i]=1;
            if(c=='I') S[j][i]=2;
        }
    }
    set<ll> ans;
    rep(i,27){
        vector<ll> cnt(N,0);
        ll i0=i%3;
        ll i1=(i%9)/3;
        ll i2=i/9;
        if((i0+i1+i2)%3!=1) continue;
        rep(j,N) cnt[j]+=S[j][0]*i0;
        rep(j,N) cnt[j]+=S[j][1]*i1;
        rep(j,N) cnt[j]+=S[j][2]*i2;
        rep(j,N) cnt[j]%=3;
        ll ANS=0;
        rep(j,N) ANS=(ANS+cnt[j]*rui[j])%mod;
        ans.insert(ANS);
    }
    ll Q;
    cin >> Q;
    vector<ll> T(N);
    rep(i,N){
        char c;
        cin >> c;
        if(c=='J') T[i]=0;
        if(c=='O') T[i]=1;
        if(c=='I') T[i]=2;
    }
    rep(i,Q+1){
        ll x=0;
        rep(j,N) x=(x+T[j]*rui[j])%mod;
        if(ans.find(x)!=ans.end()){
            cout << "Yes" << '\n';
        }    
        else cout << "No" << '\n';
        if(i==Q) break;
        ll l,r;
        char c;
        cin >> l >> r >> c;
        l--,r--;
        ll C=-1;
        if(c=='J') C=0;
        if(c=='O') C=1;
        if(c=='I') C=2;
        for(ll j=l;j<=r;j++){
            T[j]=C; 
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 363 ms 740 KB Output is correct
2 Correct 478 ms 796 KB Output is correct
3 Correct 408 ms 852 KB Output is correct
4 Correct 408 ms 848 KB Output is correct
5 Correct 367 ms 764 KB Output is correct
6 Correct 368 ms 1096 KB Output is correct
7 Correct 383 ms 956 KB Output is correct
8 Correct 433 ms 928 KB Output is correct
9 Correct 399 ms 812 KB Output is correct
10 Correct 418 ms 840 KB Output is correct
11 Correct 386 ms 2416 KB Output is correct
12 Correct 401 ms 2380 KB Output is correct
13 Correct 409 ms 2344 KB Output is correct
14 Correct 413 ms 2336 KB Output is correct
15 Correct 425 ms 2372 KB Output is correct
16 Correct 417 ms 2368 KB Output is correct
17 Correct 387 ms 2300 KB Output is correct
18 Correct 419 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 740 KB Output is correct
2 Correct 478 ms 796 KB Output is correct
3 Correct 408 ms 852 KB Output is correct
4 Correct 408 ms 848 KB Output is correct
5 Correct 367 ms 764 KB Output is correct
6 Correct 368 ms 1096 KB Output is correct
7 Correct 383 ms 956 KB Output is correct
8 Correct 433 ms 928 KB Output is correct
9 Correct 399 ms 812 KB Output is correct
10 Correct 418 ms 840 KB Output is correct
11 Correct 386 ms 2416 KB Output is correct
12 Correct 401 ms 2380 KB Output is correct
13 Correct 409 ms 2344 KB Output is correct
14 Correct 413 ms 2336 KB Output is correct
15 Correct 425 ms 2372 KB Output is correct
16 Correct 417 ms 2368 KB Output is correct
17 Correct 387 ms 2300 KB Output is correct
18 Correct 419 ms 2304 KB Output is correct
19 Execution timed out 7024 ms 13976 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 363 ms 740 KB Output is correct
2 Correct 478 ms 796 KB Output is correct
3 Correct 408 ms 852 KB Output is correct
4 Correct 408 ms 848 KB Output is correct
5 Correct 367 ms 764 KB Output is correct
6 Correct 368 ms 1096 KB Output is correct
7 Correct 383 ms 956 KB Output is correct
8 Correct 433 ms 928 KB Output is correct
9 Correct 399 ms 812 KB Output is correct
10 Correct 418 ms 840 KB Output is correct
11 Correct 386 ms 2416 KB Output is correct
12 Correct 401 ms 2380 KB Output is correct
13 Correct 409 ms 2344 KB Output is correct
14 Correct 413 ms 2336 KB Output is correct
15 Correct 425 ms 2372 KB Output is correct
16 Correct 417 ms 2368 KB Output is correct
17 Correct 387 ms 2300 KB Output is correct
18 Correct 419 ms 2304 KB Output is correct
19 Correct 388 ms 2224 KB Output is correct
20 Correct 410 ms 2356 KB Output is correct
21 Correct 411 ms 2416 KB Output is correct
22 Correct 337 ms 2148 KB Output is correct
23 Correct 448 ms 2524 KB Output is correct
24 Correct 375 ms 2320 KB Output is correct
25 Correct 403 ms 2388 KB Output is correct
26 Correct 359 ms 2252 KB Output is correct
27 Correct 389 ms 2508 KB Output is correct
28 Correct 351 ms 2192 KB Output is correct
29 Correct 387 ms 2508 KB Output is correct
30 Correct 355 ms 2124 KB Output is correct
31 Correct 390 ms 2380 KB Output is correct
32 Correct 451 ms 2412 KB Output is correct
33 Correct 424 ms 2436 KB Output is correct
34 Correct 373 ms 2284 KB Output is correct
35 Correct 401 ms 2372 KB Output is correct
36 Correct 389 ms 2388 KB Output is correct
37 Correct 406 ms 2344 KB Output is correct
38 Correct 385 ms 2412 KB Output is correct
39 Correct 405 ms 2388 KB Output is correct
40 Correct 391 ms 2380 KB Output is correct
41 Correct 396 ms 2500 KB Output is correct
42 Correct 405 ms 2364 KB Output is correct
43 Correct 380 ms 2380 KB Output is correct
44 Correct 418 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 740 KB Output is correct
2 Correct 478 ms 796 KB Output is correct
3 Correct 408 ms 852 KB Output is correct
4 Correct 408 ms 848 KB Output is correct
5 Correct 367 ms 764 KB Output is correct
6 Correct 368 ms 1096 KB Output is correct
7 Correct 383 ms 956 KB Output is correct
8 Correct 433 ms 928 KB Output is correct
9 Correct 399 ms 812 KB Output is correct
10 Correct 418 ms 840 KB Output is correct
11 Correct 386 ms 2416 KB Output is correct
12 Correct 401 ms 2380 KB Output is correct
13 Correct 409 ms 2344 KB Output is correct
14 Correct 413 ms 2336 KB Output is correct
15 Correct 425 ms 2372 KB Output is correct
16 Correct 417 ms 2368 KB Output is correct
17 Correct 387 ms 2300 KB Output is correct
18 Correct 419 ms 2304 KB Output is correct
19 Execution timed out 7024 ms 13976 KB Time limit exceeded
20 Halted 0 ms 0 KB -