結果

問題 No.397 NO MORE KADOMATSU
ユーザー gumfumgumfum
提出日時 2016-07-16 00:08:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,334 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 89,360 KB
実行使用メモリ 24,360 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:18:42
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,000 KB
testcase_01 AC 23 ms
24,348 KB
testcase_02 AC 23 ms
24,000 KB
testcase_03 AC 26 ms
24,300 KB
testcase_04 AC 25 ms
23,352 KB
testcase_05 AC 25 ms
24,324 KB
testcase_06 AC 27 ms
24,360 KB
testcase_07 AC 28 ms
24,048 KB
testcase_08 AC 24 ms
23,496 KB
testcase_09 AC 24 ms
24,048 KB
testcase_10 AC 53 ms
23,352 KB
testcase_11 AC 24 ms
24,300 KB
testcase_12 AC 32 ms
23,628 KB
testcase_13 AC 34 ms
23,508 KB
testcase_14 AC 35 ms
24,240 KB
testcase_15 AC 35 ms
23,808 KB
testcase_16 AC 23 ms
23,820 KB
testcase_17 AC 24 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int N;
	cin >> N;
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}

	vector<pii> ans;
	REP(i, N) {
		FOR(j, 1, N-i-1) {
			if (A[j] < A[j - 1]) {
				int tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				ans.push_back(pii(j - 1, j));
			}
		}
	}

	int size = ans.size();
	cout << size << endl;
	REP(i, size) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	cin >> N;
	cout << flush;
	return 0;
}
0