結果
問題 | No.619 CardShuffle |
ユーザー | tails |
提出日時 | 2017-12-19 11:10:39 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,396 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-02 04:30:49 |
合計ジャッジ時間 | 3,394 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 3 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 3 ms
6,944 KB |
testcase_09 | AC | 3 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 87 ms
6,940 KB |
testcase_19 | AC | 76 ms
6,940 KB |
testcase_20 | AC | 79 ms
6,940 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 86 ms
6,940 KB |
testcase_24 | AC | 71 ms
6,940 KB |
testcase_25 | AC | 71 ms
6,944 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 92 ms
6,940 KB |
testcase_29 | AC | 78 ms
6,944 KB |
testcase_30 | AC | 81 ms
6,940 KB |
testcase_31 | AC | 3 ms
6,940 KB |
testcase_32 | AC | 79 ms
6,944 KB |
testcase_33 | AC | 84 ms
6,944 KB |
testcase_34 | AC | 79 ms
6,940 KB |
testcase_35 | WA | - |
コンパイルメッセージ
main.c:131:1: warning: return type defaults to 'int' [-Wimplicit-int] 131 | main(n,q,i,c,d,t,x,y){ | ^~~~ main.c: In function 'main': main.c:131:1: warning: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'q' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'd' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 't' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:131:1: warning: type of 'y' defaults to 'int' [-Wimplicit-int] main.c:132:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 132 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #define M 1000000007 main.c:132:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 132 | scanf("%d",&n); | ^~~~~ main.c:132:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:161:25: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 161 | printf("%d\n",(0ll+nd.l+nd.r+nd.m)%M); | ^~~~~~ main.c:161:25: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:161:25: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:161:25: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
#define M 1000000007 typedef struct{ int l,r,m; } N; N ns[1<<17]; int nn; int ds[1<<16]; int ops[1<<16]; void nmul(N*p1,N*p2,N*pd){ if(p1->r==0&&p2->r==0){ pd->l=1ll*p1->l*p2->l%M; pd->r=0; pd->m=0; } if(p1->r==0&&p2->r!=0){ pd->l=1ll*p1->l*p2->l%M; pd->r=p2->r; pd->m=p2->m; } if(p1->r!=0&&p2->r==0){ pd->l=p1->l; pd->r=1ll*p1->r*p2->l%M; pd->m=p1->m; } if(p1->r!=0&&p2->r!=0){ pd->l=p1->l; pd->r=p2->r; pd->m=(p1->m+1ll*p1->r*p2->l+p2->m)%M; } } void nadd(N*p1,N*p2,N*pd){ if(p1->r==0&&p2->r==0){ pd->l=p1->l; pd->r=p2->l; pd->m=0; } if(p1->r==0&&p2->r!=0){ pd->l=p1->l; pd->r=p2->r; pd->m=(p2->l+p2->m)%M; } if(p1->r!=0&&p2->r==0){ pd->l=p1->l; pd->r=p2->l; pd->m=(p1->r+p1->m)%M; } if(p1->r!=0&&p2->r!=0){ pd->l=p1->l; pd->r=p2->r; pd->m=(0ll+p1->m+p1->r+p2->l+p2->m)%M; } } void mk(int l,int r,int i){ int i1=i*2+1; int i2=i*2+2; if(l==r-1){ // leaf ns[i].l=ds[l]; ns[i].r=0; ns[i].m=0; }else{ // inter int c=(l+r)/2; mk(l,c,i1); mk(c,r,i2); int op=ops[c]; if(op=='*'){ nmul(ns+i1,ns+i2,ns+i); }else{ nadd(ns+i1,ns+i2,ns+i); } } } void remk(int l,int r,int i,int j){ int i1=i*2+1; int i2=i*2+2; if(l==r-1){ // leaf ns[i].l=ds[l]; ns[i].r=0; ns[i].m=0; }else{ // inter int c=(l+r)/2; if(j<c)remk(l,c,i1,j); else remk(c,r,i2,j); int op=ops[c]; if(op=='*'){ nmul(ns+i1,ns+i2,ns+i); }else{ nadd(ns+i1,ns+i2,ns+i); } } } N f(int l,int r,int i,int x,int y){ N*p=ns+i; if(x<=l&&y>=r){ return ns[i]; } int c=(l+r)/2; if(y<=c){ return f(l,c,i*2+1,x,y); } if(x>=c){ return f(c,r,i*2+2,x,y); } { N nd; N nl=f(l,c,i*2+1,x,y); N nr=f(c,r,i*2+2,x,y); int op=ops[c]; if(op=='*'){ nmul(&nl,&nr,&nd); }else{ nadd(&nl,&nr,&nd); } return nd; } } void dbg_bp(){ } main(n,q,i,c,d,t,x,y){ scanf("%d",&n); scanf("%d",ds+0); for(i=1;i<n/2+1;++i){ scanf(" %s%d",ops+i,ds+i); } mk(0,1<<16,0); scanf("%d",&q); for(i=0;i<q;++i){ t=0; scanf(" %s%d%d",&t,&x,&y); if(t=='!'){ if(x%2){ // digit t=ds[x/2]; ds[x/2]=ds[y/2]; ds[y/2]=t; remk(0,1<<16,0,x/2); remk(0,1<<16,0,y/2); }else{ // op t=ops[x/2]; ops[x/2]=ops[y/2]; ops[y/2]=t; remk(0,1<<16,0,x/2); remk(0,1<<16,0,y/2); } }else{ N nd=f(0,1<<16,0,x/2,y/2+1); printf("%d\n",(0ll+nd.l+nd.r+nd.m)%M); } } }