結果

問題 No.397 NO MORE KADOMATSU
ユーザー T1610T1610
提出日時 2019-04-01 01:58:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 168,940 KB
実行使用メモリ 24,324 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 02:11:23
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,640 KB
testcase_01 AC 24 ms
23,640 KB
testcase_02 AC 24 ms
23,520 KB
testcase_03 AC 27 ms
23,652 KB
testcase_04 AC 25 ms
24,012 KB
testcase_05 AC 26 ms
23,436 KB
testcase_06 AC 28 ms
23,988 KB
testcase_07 AC 28 ms
24,312 KB
testcase_08 AC 25 ms
23,856 KB
testcase_09 AC 24 ms
23,652 KB
testcase_10 AC 43 ms
23,388 KB
testcase_11 AC 25 ms
24,000 KB
testcase_12 AC 31 ms
23,556 KB
testcase_13 AC 34 ms
23,820 KB
testcase_14 AC 34 ms
24,240 KB
testcase_15 AC 34 ms
24,324 KB
testcase_16 AC 26 ms
24,012 KB
testcase_17 AC 26 ms
23,568 KB
権限があれば一括ダウンロードができます

ソースコード

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