結果

問題 No.2992 Range ABCD String Query
ユーザー Iroha_3856Iroha_3856
提出日時 2024-12-17 01:31:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 752 ms / 6,000 ms
コード長 573 bytes
コンパイル時間 11,111 ms
コンパイル使用メモリ 252,500 KB
実行使用メモリ 48,948 KB
最終ジャッジ日時 2024-12-17 01:33:38
合計ジャッジ時間 25,833 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
6,820 KB
testcase_01 AC 264 ms
6,820 KB
testcase_02 AC 287 ms
6,820 KB
testcase_03 AC 276 ms
6,816 KB
testcase_04 AC 297 ms
6,816 KB
testcase_05 AC 286 ms
6,820 KB
testcase_06 AC 293 ms
6,816 KB
testcase_07 AC 242 ms
6,816 KB
testcase_08 AC 299 ms
6,816 KB
testcase_09 AC 272 ms
6,820 KB
testcase_10 AC 604 ms
47,532 KB
testcase_11 AC 568 ms
46,716 KB
testcase_12 AC 591 ms
46,928 KB
testcase_13 AC 552 ms
45,268 KB
testcase_14 AC 566 ms
44,604 KB
testcase_15 AC 552 ms
44,824 KB
testcase_16 AC 528 ms
27,384 KB
testcase_17 AC 574 ms
48,588 KB
testcase_18 AC 550 ms
44,576 KB
testcase_19 AC 575 ms
48,700 KB
testcase_20 AC 468 ms
48,768 KB
testcase_21 AC 467 ms
48,948 KB
testcase_22 AC 458 ms
48,760 KB
testcase_23 AC 459 ms
48,904 KB
testcase_24 AC 468 ms
48,760 KB
testcase_25 AC 389 ms
48,856 KB
testcase_26 AC 395 ms
48,864 KB
testcase_27 AC 398 ms
48,876 KB
testcase_28 AC 404 ms
48,788 KB
testcase_29 AC 394 ms
48,860 KB
testcase_30 AC 629 ms
48,876 KB
testcase_31 AC 617 ms
48,804 KB
testcase_32 AC 613 ms
48,828 KB
testcase_33 AC 620 ms
48,868 KB
testcase_34 AC 619 ms
48,832 KB
testcase_35 AC 752 ms
48,832 KB
testcase_36 AC 740 ms
48,800 KB
testcase_37 AC 228 ms
6,816 KB
testcase_38 AC 236 ms
6,816 KB
testcase_39 AC 238 ms
6,816 KB
testcase_40 AC 242 ms
6,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:234: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | struct S{q D[4][4];S(){c(i,0,4)c(j,0,4)D[i][j]=0;}S(q x){c(i,0,4)c(j,0,4)D[i][j]=(i<=x&&x<=j?0:1);}};S o(S L,S R){S K;c(i,0,4)c(j,i,4){K.D[i][j]=1e9;c(k,i,j+1)K.D[i][j]=min(K.D[i][j],L.D[i][k]+R.D[k][j]);}return K;}S e(){return S();}main(){q N,Q,l;string T;cin>>N>>Q>>T;vector<S>A(N);c(i,0,N)A[i]=S(T[i]-'A');atcoder::segtree<S,o,e>g(A);while(Q--){cin>>N;if(--N){cin>>N>>l;cout<<g.prod(N-1,l).D[0][3]<<endl;}else{char c;cin>>l>>c;g.set(l-1,S(c-'A'));}}}
      |                                                                                                                                                                                                                                          ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/segtree>
#define q int
#define c(i,v,n)for(q i=v;i<n;i++)
struct S{q D[4][4];S(){c(i,0,4)c(j,0,4)D[i][j]=0;}S(q x){c(i,0,4)c(j,0,4)D[i][j]=(i<=x&&x<=j?0:1);}};S o(S L,S R){S K;c(i,0,4)c(j,i,4){K.D[i][j]=1e9;c(k,i,j+1)K.D[i][j]=min(K.D[i][j],L.D[i][k]+R.D[k][j]);}return K;}S e(){return S();}main(){q N,Q,l;string T;cin>>N>>Q>>T;vector<S>A(N);c(i,0,N)A[i]=S(T[i]-'A');atcoder::segtree<S,o,e>g(A);while(Q--){cin>>N;if(--N){cin>>N>>l;cout<<g.prod(N-1,l).D[0][3]<<endl;}else{char c;cin>>l>>c;g.set(l-1,S(c-'A'));}}}
0