結果

問題 No.397 NO MORE KADOMATSU
ユーザー latte0119latte0119
提出日時 2016-07-16 16:14:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 70,656 KB
実行使用メモリ 24,396 KB
平均クエリ数 30.78
最終ジャッジ日時 2023-09-23 11:10:22
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<cstdlib>
#include<string>
#include<numeric>
using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool f(int a,int b,int c){
    if(a==b||b==c||c==a)return false;
    if(a>b&&c>b)return true;
    if(a<b&&c<b)return true;
    return false;
}

signed main(){
    int N;
    int A[100];
    cin>>N;
    rep(i,N)cin>>A[i];
    vpint ans;
    rep(i,N-2){
        if(f(A[i],A[i+1],A[i+2])){
            ans.pb(pint(i+1,i+2));
            swap(A[i+1],A[i+2]);
        }
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i].first<<" "<<ans[i].second<<endl;
    int tmp;cin>>tmp;
    return 0;
}
0