結果

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

テストケース

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

ソースコード

diff #

#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"<<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,3)a.push_back(i+j);
    }
  }
  assert(a.size()!=0);
  if(a.size()>=200)f();
  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);
      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();
}
0