結果
問題 | No.1707 Simple Range Reverse Problem |
ユーザー | 👑Zack Ni |
提出日時 | 2021-10-15 21:41:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,188 bytes |
コンパイル時間 | 2,027 ms |
コンパイル使用メモリ | 180,348 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-17 20:08:48 |
合計ジャッジ時間 | 2,754 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
4,348 KB |
testcase_15 | AC | 2 ms
4,348 KB |
testcase_16 | AC | 2 ms
4,348 KB |
testcase_17 | AC | 2 ms
4,348 KB |
testcase_18 | AC | 2 ms
4,348 KB |
ソースコード
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } inline void rd(int &x){ int k; int m=0; x=0; for(;;){ k = my_getchar(); if(k=='-'){ m=1; break; } if('0'<=k&&k<='9'){ x=k-'0'; break; } } for(;;){ k = my_getchar(); if(k<'0'||k>'9'){ break; } x=x*10+k-'0'; } if(m){ x=-x; } } inline int rd_int(void){ int x; rd(x); return x; } struct MY_WRITER{ char buf[1048576]; int s; int e; MY_WRITER(){ s = 0; e = 1048576; } ~MY_WRITER(){ if(s){ fwrite(buf, 1, s, stdout); } } } ; MY_WRITER MY_WRITER_VAR; void my_putchar(int a){ if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){ fwrite(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout); MY_WRITER_VAR.s = 0; } MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a; } inline void wt_L(char a){ my_putchar(a); } inline void wt_L(const char c[]){ int i=0; for(i=0;c[i]!='\0';i++){ my_putchar(c[i]); } } template<class S, class T> inline S chmin(S &a, T b){ if(a>b){ a=b; } return a; } template<class S, class T> inline S chmax(S &a, T b){ if(a<b){ a=b; } return a; } int a[1000+10]; int b[1000+10]; int main(){ int PiIOrLma; int AuJVIghY = rd_int(); for(PiIOrLma=(0);PiIOrLma<(AuJVIghY);PiIOrLma++){ int i; int N; rd(N); { int djQeACzd; for(djQeACzd=(0);djQeACzd<(2*N);djQeACzd++){ rd(a[djQeACzd]); } } for(i=(0);i<(N);i++){ b[i] = b[i+N] = i+1; } int lun = 1073709056; int run = -1; for(i=(0);i<(2*N);i++){ if(a[i] != b[i]){ chmin(lun, i-1); chmax(run, i+1); } } if(lun >= 1073709056 || run < 0){ wt_L("Yes"); wt_L('\n'); continue; } if(lun < 0 || run >= 2 * N){ wt_L("No"); wt_L('\n'); continue; } reverse(b+lun, b + run + 1); for(i=(0);i<(2*N);i++){ if(a[i] != b[i]){ wt_L("No"); wt_L('\n'); goto FJNsjZ7B; } } wt_L("Yes"); wt_L('\n'); FJNsjZ7B:; } return 0; } // cLay version 20210405-1 // --- original code --- // //no-unlocked // int a[1d3+10]; // int b[1d3+10]; // { // REP(rd_int()){ // int N; // rd(N, a(2*N)); // rep(i, N) b[i] = b[i+N] = i+1; // int lun = int_inf, run = -1; // rep(i, 2*N){ // if(a[i] != b[i]){ // lun <?= i-1; // run >?= i+1; // } // } // if(lun >= int_inf || run < 0){ // wt("Yes"); continue; // } // //wt(lun, run); // if(lun < 0 || run >= 2 * N){ // wt("No"); continue; // } // reverse(b+lun, b + run + 1); // rep(i, 2*N){ // if(a[i] != b[i]){ // wt("No"); // break_continue; // } // } // wt("Yes"); // } // }