結果

問題 No.397 NO MORE KADOMATSU
ユーザー tkmst201tkmst201
提出日時 2017-04-15 16:47:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 147,556 KB
実行使用メモリ 24,420 KB
平均クエリ数 819.72
最終ジャッジ日時 2023-09-24 00:57:41
合計ジャッジ時間 3,041 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,640 KB
testcase_01 AC 23 ms
23,388 KB
testcase_02 AC 24 ms
24,396 KB
testcase_03 AC 31 ms
23,352 KB
testcase_04 AC 24 ms
23,376 KB
testcase_05 AC 30 ms
23,400 KB
testcase_06 AC 27 ms
23,652 KB
testcase_07 AC 27 ms
23,832 KB
testcase_08 AC 25 ms
24,420 KB
testcase_09 AC 23 ms
23,220 KB
testcase_10 AC 24 ms
24,384 KB
testcase_11 AC 23 ms
23,388 KB
testcase_12 AC 31 ms
24,000 KB
testcase_13 AC 32 ms
23,544 KB
testcase_14 AC 33 ms
23,412 KB
testcase_15 AC 33 ms
23,520 KB
testcase_16 AC 24 ms
23,364 KB
testcase_17 AC 24 ms
23,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n;
	int a[100];
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	vector<pii> ans;
	
	REP(i, n) FOR(j, 1, n - i) {
		if (a[j] > a[j - 1]) {
			ans.push_back(pii(j - 1, j));
			swap(a[j], a[j - 1]); 
		}
	}
	
	cout << ans.size() << endl;
	REP(i, ans.size()) printf("%d %d\n", ans[i].first, ans[i].second);
	fflush(stdout);
	
	int dummy;
	cin >> dummy;
	return 0;
}
0