結果
| 問題 |
No.1369 交換門松列・竹
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2019-11-09 14:21:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 928 bytes |
| コンパイル時間 | 994 ms |
| コンパイル使用メモリ | 77,896 KB |
| 最終ジャッジ日時 | 2025-01-08 03:45:31 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 10 WA * 23 |
ソースコード
#include<algorithm>
#include<iostream>
#include<vector>
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"<<endl;
exit(0);
}
bool kado(int i){
if(i<=0||i>=n-1)return 1;
if(c[i+1]==c[i-1])return 0;
return (c[i]-c[i+1])*(c[i]-c[i-1])>0;
}
int main(){
cin>>n;
rep(i,n)cin>>c[i];
vi a;
rep(i,n-2){
if(!kado(i+1)){
a.push_back(i+1);
a.push_back(i);
a.push_back(i+2);
}
}
if(a.size()>=100)f();
for(int b:a){
rep(i,n){
if(b==i)continue;
swap(c[i],c[b]);
vi tt(a);
rep(j,3)tt.push_back(i+j-1);
rep(j,3)tt.push_back(b+j-1);
int ok=1;
for(int t:tt)if(!kado(t)){ok=0;break;}
if(ok){cout<<"Yes"<<endl;return 0;}
swap(c[i],c[b]);
}
}
f();
}
夕叢霧香(ゆうむらきりか)