結果

問題 No.398 ハーフパイプ(2)
ユーザー T1610T1610
提出日時 2019-04-01 01:58:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 169,628 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 03:01:01
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    vector<int> a;
    rep(i, N) rep(j, N-1) if(v[j] > v[j+1]) {
        // cout << j << " " << j+1 << '\n';
        a.pb(j);
        swap(v[j], v[j+1]);
    }
    cout << a.size() << '\n';
    rep(i, a.size()) cout << a[i] << " " << a[i]+1 << '\n';
    cout << flush;
    int d;
    cin >> d;
    return 0;
}
0