結果

問題 No.397 NO MORE KADOMATSU
ユーザー itezpaceitezpace
提出日時 2016-07-15 23:23:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 151,084 KB
実行使用メモリ 535,172 KB
平均クエリ数 22.56
最終ジャッジ日時 2023-09-23 11:05:39
合計ジャッジ時間 5,728 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,844 KB
testcase_01 WA -
testcase_02 AC 25 ms
23,400 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int n,a,d;
  cin>>n;
  vector<int> v;
  for(int i=0; i<n; ++i){
    cin>>a;
    v.push_back(a);
  }
  int f;
  f=0;
  int c;
  c=0;
  vector<pair<int,int>> vp;
  while(1){
    for(int i=1; i<n-1; ++i){
      int x,y,z;
      x=v[i-1];
      y=v[i];
      z=v[i+1];
      if(x<y && y>z){
        v.erase(v.begin()+i);
        v.insert(v.begin()+n-1,y);
        f=1;
        c++;
        pair<int,int> p;
        p=make_pair(i,n-1);
        vp.push_back(p);
      }
      if(x>y && y<z){
        v.erase(v.begin()+i);
        v.insert(v.begin()+0,y);
        f=1;
        c++;
        pair<int,int> p;
        p=make_pair(0,i);
        vp.push_back(p);
      }
    }
    if(f==0){
      break;
    }
    f=0;
  }
  cout<<c<<endl;
  pair<int,int> p;
  for(int i=0; i<vp.size(); ++i){
    p=vp[i];
    cout<<p.first<<" "<<p.second<<endl;
  }
  cin>>d;
  return 0;
}
0