結果
問題 |
No.1369 交換門松列・竹
|
ユーザー |
![]() |
提出日時 | 2020-11-03 19:49:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,141 bytes |
コンパイル時間 | 948 ms |
コンパイル使用メモリ | 78,456 KB |
最終ジャッジ日時 | 2025-01-15 19:26:54 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 WA * 1 TLE * 2 |
ソースコード
#include<algorithm> #include<iostream> #include<vector> #include<cassert> using namespace std; typedef long long lint; typedef vector<int>vi; typedef pair<int,int>pii; #define rep(i,n)for(int i=0;i<(int)(n);++i) // https://yukicoder.me/problems/3422 #define N 50000 int n; int c[N]; void f(){ cout<<"No\n"; } bool kado(int i){ if(i<=0||i>=n-1)return 1; if(c[i+1]==c[i-1])return 0; return lint(c[i]-c[i+1])*(c[i]-c[i-1])>0; } // WA int main(){ int t; cin>>t; rep(_,t){ cin>>n; assert(n<=N); rep(i,n){cin>>c[i];assert(1<=c[i]&&c[i]<=n);} vi a; rep(i,n-2){ if(!kado(i+1)){ rep(j,3)a.push_back(i+j); } } assert(a.size()!=0); if(a.size()>=200)f(); int ans=0; for(int b:a){ if(b<0||b>=n)continue; rep(i,n){ if(b==i)continue; swap(c[i],c[b]); vi tt(a); //WA: 範囲を間違える rep(j,3)tt.push_back(i+j-1); tt.push_back(b); int ok=1; for(int t:tt)if(!kado(t)){ok=0;break;} if(ok){ans=1;goto end;} swap(c[i],c[b]); } } end: cout<<(ans?"Yes":"No")<<"\n"; } }