結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー | tails |
提出日時 | 2024-12-03 15:22:00 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 1,743 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 28,288 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-03 15:22:16 |
合計ジャッジ時間 | 14,361 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 57 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:17:1: warning: implicit declaration of function ‘setpriority’ [-Wimplicit-function-declaration] 17 | setpriority(0,0,0); | ^~~~~~~~~~~ main.c:5:48: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) | ^~~~ main.c:6:37: note: in expansion of macro ‘rd_getc’ 6 | #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) | ^~~~~~~ main.c:18:15: note: in expansion of macro ‘rd’ 18 | int n=rd(); // n=1000 | ^~ main.c:5:70: warning: implicit declaration of function ‘dprintf’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) | ^~~~~~~ main.c:6:37: note: in expansion of macro ‘rd_getc’ 6 | #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) | ^~~~~~~ main.c:18:15: note: in expansion of macro ‘rd’ 18 | int n=rd(); // n=1000 | ^~ main.c:34:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] 34 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:106:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] 106 | _exit(0); | ^~~~~ main.c:106:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rbufsize 65536 #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) {unsigned _z=v,_n=0;long _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define rep(v,e) for(typeof(e)v=0;v<e;++v) char wbuf[1<<25]; char rbuf[rbufsize]; int rpos,rend; int a[500]; int b[500]; int main(){ setpriority(0,0,0); int n=rd(); // n=1000 int q=rd(); // q=1500 { char*wp=wbuf; rep(i,n>>1){ *wp++='?'; *wp++=' '; wt(i*2+1); *wp++=' '; wt(n); *wp++=' '; wt(i*2+2); *wp++=' '; wt(n); *wp++='\n'; } write(1,wbuf,wp-wbuf); rep(i,n>>1){ if(rd_getc()&1){ a[i]=i*2+1; b[i]=i*2+2; }else{ a[i]=i*2+2; b[i]=i*2+1; } rd_getc(); } } for(int m=n>>1;m>1;m=m+1>>1){ char*wp=wbuf; rep(i,m>>1){ *wp++='?'; *wp++=' '; wt(a[i*2+0]); *wp++=' '; wt(a[i*2+0]); *wp++=' '; wt(a[i*2+1]); *wp++=' '; wt(a[i*2+1]); *wp++='\n'; } rep(i,m>>1){ *wp++='?'; *wp++=' '; wt(b[i*2+0]); *wp++=' '; wt(n); *wp++=' '; wt(b[i*2+1]); *wp++=' '; wt(n); *wp++='\n'; } write(1,wbuf,wp-wbuf); rep(i,m>>1){ if(rd_getc()&1){ a[i]=a[i*2+0]; }else{ a[i]=a[i*2+1]; } rd_getc(); } rep(i,m>>1){ if(rd_getc()&1){ b[i]=b[i*2+1]; }else{ b[i]=b[i*2+0]; } rd_getc(); } a[m>>1]=a[m-1]; b[m>>1]=b[m-1]; } { char*wp=wbuf; *wp++='!'; *wp++=' '; wt(a[0]); *wp++=' '; wt(a[0]); *wp++=' '; wt(b[0]); *wp++=' '; wt(n); *wp++='\n'; write(1,wbuf,wp-wbuf); } _exit(0); }