結果

問題 No.1369 交換門松列・竹
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2019-11-09 14:31:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 80,000 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 15:06:29
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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)){
      rep(j,5)a.push_back(i+j-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,5)tt.push_back(i+j-2);
      rep(j,5)tt.push_back(b+j-2);
      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();
}
0