結果
問題 | No.2069 み世界数式 |
ユーザー | tails |
提出日時 | 2022-09-11 00:03:50 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 2,139 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 28,640 KB |
実行使用メモリ | 10,732 KB |
最終ジャッジ日時 | 2023-08-18 04:52:27 |
合計ジャッジ時間 | 5,120 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 0 ms
4,376 KB |
testcase_04 | AC | 0 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 0 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 4 ms
6,560 KB |
testcase_13 | AC | 4 ms
6,704 KB |
testcase_14 | AC | 3 ms
6,608 KB |
testcase_15 | AC | 3 ms
6,664 KB |
testcase_16 | AC | 6 ms
6,764 KB |
testcase_17 | AC | 3 ms
6,640 KB |
testcase_18 | AC | 5 ms
6,688 KB |
testcase_19 | AC | 5 ms
6,700 KB |
testcase_20 | AC | 4 ms
6,852 KB |
testcase_21 | AC | 3 ms
6,568 KB |
testcase_22 | AC | 8 ms
6,876 KB |
testcase_23 | AC | 6 ms
6,628 KB |
testcase_24 | AC | 5 ms
6,664 KB |
testcase_25 | AC | 5 ms
6,732 KB |
testcase_26 | AC | 6 ms
6,760 KB |
testcase_27 | AC | 1 ms
4,380 KB |
testcase_28 | AC | 1 ms
4,376 KB |
testcase_29 | AC | 1 ms
4,376 KB |
testcase_30 | AC | 0 ms
4,380 KB |
testcase_31 | AC | 1 ms
4,376 KB |
testcase_32 | AC | 0 ms
4,376 KB |
testcase_33 | AC | 1 ms
4,376 KB |
testcase_34 | AC | 1 ms
4,384 KB |
testcase_35 | AC | 1 ms
4,380 KB |
testcase_36 | AC | 0 ms
4,384 KB |
testcase_37 | AC | 17 ms
10,732 KB |
testcase_38 | AC | 8 ms
9,128 KB |
testcase_39 | AC | 0 ms
4,380 KB |
testcase_40 | AC | 2 ms
4,380 KB |
testcase_41 | AC | 1 ms
4,380 KB |
testcase_42 | AC | 2 ms
4,380 KB |
testcase_43 | AC | 1 ms
4,376 KB |
testcase_44 | AC | 3 ms
4,484 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:123:2: warning: implicit declaration of function ‘read’; did you mean ‘rd’? [-Wimplicit-function-declaration] read(0,buf,sizeof buf); ^~~~ rd main.c:130:3: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] write(1,"-1\n",3); ^~~~~ main.c:135:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] _exit(0); ^~~~~ main.c:135:2: warning: incompatible implicit declaration of built-in function ‘_exit’
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) typedef unsigned long ulong; char buf[1024]; struct A { int op; char* ep; struct A* c1; struct A* c2; }; struct B { struct A a[301]; }; struct B pool[8192]; struct B* pp=pool; struct B* eval(char**epp,long m){ char*e=*epp; struct B*mul=0; struct B*add=0; char*mulp=0; char*addp=0; while(1){ struct B*cur; if(*e=='('){ ++e; cur=eval(&e,m); }else{ long v=0; for(long c;c=*e-'0',c>=0&&c<=9;e++){ v=v*10+c; } cur=pp++; cur->a[v].op='0'; } { char*curp=e++; if(mul){ struct B*r=pp++; for(int x=0;x<=m;++x){ if(mul->a[x].op){ for(int y=0;y<=m;++y){ if(cur->a[y].op){ if(y){ struct A*a=&r->a[x/y]; a->op='/'; a->c1=&mul->a[x]; a->c2=&cur->a[y]; a->ep=mulp; } if(x*y<=m){ struct A*a=&r->a[x*y]; a->op='*'; a->c1=&mul->a[x]; a->c2=&cur->a[y]; a->ep=mulp; } } } } } mul=r; }else{ mul=cur; } mulp=curp; } if(*mulp!='&'){ if(add){ struct B*r=pp++; for(int x=0;x<=m;++x){ if(add->a[x].op){ for(int y=0;y<=m;++y){ if(mul->a[y].op){ if(x-y>=0){ struct A*a=&r->a[x-y]; a->op='-'; a->c1=&add->a[x]; a->c2=&mul->a[y]; a->ep=addp; } if(x+y<=m){ struct A*a=&r->a[x+y]; a->op='+'; a->c1=&add->a[x]; a->c2=&mul->a[y]; a->ep=addp; } } } } } add=r; }else{ add=mul; } mul=0; addp=mulp; if(*addp=='\n'||*addp==')'){ break; } } } *epp=e; return add; } void apply(struct A*a){ if(a){ if(a->ep) *a->ep=a->op; apply(a->c1); apply(a->c2); } } int main(){ read(0,buf,sizeof buf); char*rp=buf; long m=rd(); long ans=rd(); char*expr=rp; struct B*b=eval(&expr,m); if(b->a[ans].op==0){ write(1,"-1\n",3); }else{ apply(&b->a[ans]); write(1,rp,expr-rp); } _exit(0); }