답안 #710987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710987 2023-03-16T06:40:55 Z zeta7532 Crossing (JOI21_crossing) C++17
26 / 100
435 ms 2596 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;
        if(N>100) return 0;
        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; 
            }
        }
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 2240 KB Output is correct
2 Correct 393 ms 2380 KB Output is correct
3 Correct 396 ms 2252 KB Output is correct
4 Correct 387 ms 2416 KB Output is correct
5 Correct 411 ms 2304 KB Output is correct
6 Correct 367 ms 2248 KB Output is correct
7 Correct 374 ms 2376 KB Output is correct
8 Correct 396 ms 2420 KB Output is correct
9 Correct 399 ms 2416 KB Output is correct
10 Correct 404 ms 2384 KB Output is correct
11 Correct 387 ms 2388 KB Output is correct
12 Correct 396 ms 2328 KB Output is correct
13 Correct 406 ms 2396 KB Output is correct
14 Correct 393 ms 2412 KB Output is correct
15 Correct 395 ms 2392 KB Output is correct
16 Correct 380 ms 2528 KB Output is correct
17 Correct 395 ms 2432 KB Output is correct
18 Correct 396 ms 2252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 2240 KB Output is correct
2 Correct 393 ms 2380 KB Output is correct
3 Correct 396 ms 2252 KB Output is correct
4 Correct 387 ms 2416 KB Output is correct
5 Correct 411 ms 2304 KB Output is correct
6 Correct 367 ms 2248 KB Output is correct
7 Correct 374 ms 2376 KB Output is correct
8 Correct 396 ms 2420 KB Output is correct
9 Correct 399 ms 2416 KB Output is correct
10 Correct 404 ms 2384 KB Output is correct
11 Correct 387 ms 2388 KB Output is correct
12 Correct 396 ms 2328 KB Output is correct
13 Correct 406 ms 2396 KB Output is correct
14 Correct 393 ms 2412 KB Output is correct
15 Correct 395 ms 2392 KB Output is correct
16 Correct 380 ms 2528 KB Output is correct
17 Correct 395 ms 2432 KB Output is correct
18 Correct 396 ms 2252 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 2240 KB Output is correct
2 Correct 393 ms 2380 KB Output is correct
3 Correct 396 ms 2252 KB Output is correct
4 Correct 387 ms 2416 KB Output is correct
5 Correct 411 ms 2304 KB Output is correct
6 Correct 367 ms 2248 KB Output is correct
7 Correct 374 ms 2376 KB Output is correct
8 Correct 396 ms 2420 KB Output is correct
9 Correct 399 ms 2416 KB Output is correct
10 Correct 404 ms 2384 KB Output is correct
11 Correct 387 ms 2388 KB Output is correct
12 Correct 396 ms 2328 KB Output is correct
13 Correct 406 ms 2396 KB Output is correct
14 Correct 393 ms 2412 KB Output is correct
15 Correct 395 ms 2392 KB Output is correct
16 Correct 380 ms 2528 KB Output is correct
17 Correct 395 ms 2432 KB Output is correct
18 Correct 396 ms 2252 KB Output is correct
19 Correct 389 ms 2260 KB Output is correct
20 Correct 402 ms 2300 KB Output is correct
21 Correct 386 ms 2484 KB Output is correct
22 Correct 336 ms 2160 KB Output is correct
23 Correct 385 ms 2380 KB Output is correct
24 Correct 373 ms 2276 KB Output is correct
25 Correct 388 ms 2348 KB Output is correct
26 Correct 359 ms 2472 KB Output is correct
27 Correct 389 ms 2380 KB Output is correct
28 Correct 352 ms 2280 KB Output is correct
29 Correct 387 ms 2400 KB Output is correct
30 Correct 349 ms 2288 KB Output is correct
31 Correct 389 ms 2340 KB Output is correct
32 Correct 395 ms 2596 KB Output is correct
33 Correct 399 ms 2412 KB Output is correct
34 Correct 356 ms 2348 KB Output is correct
35 Correct 386 ms 2420 KB Output is correct
36 Correct 389 ms 2416 KB Output is correct
37 Correct 393 ms 2420 KB Output is correct
38 Correct 391 ms 2332 KB Output is correct
39 Correct 396 ms 2364 KB Output is correct
40 Correct 408 ms 2392 KB Output is correct
41 Correct 410 ms 2512 KB Output is correct
42 Correct 398 ms 2432 KB Output is correct
43 Correct 435 ms 2308 KB Output is correct
44 Correct 424 ms 2380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 2240 KB Output is correct
2 Correct 393 ms 2380 KB Output is correct
3 Correct 396 ms 2252 KB Output is correct
4 Correct 387 ms 2416 KB Output is correct
5 Correct 411 ms 2304 KB Output is correct
6 Correct 367 ms 2248 KB Output is correct
7 Correct 374 ms 2376 KB Output is correct
8 Correct 396 ms 2420 KB Output is correct
9 Correct 399 ms 2416 KB Output is correct
10 Correct 404 ms 2384 KB Output is correct
11 Correct 387 ms 2388 KB Output is correct
12 Correct 396 ms 2328 KB Output is correct
13 Correct 406 ms 2396 KB Output is correct
14 Correct 393 ms 2412 KB Output is correct
15 Correct 395 ms 2392 KB Output is correct
16 Correct 380 ms 2528 KB Output is correct
17 Correct 395 ms 2432 KB Output is correct
18 Correct 396 ms 2252 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -