結果

問題 No.397 NO MORE KADOMATSU
ユーザー nksk38nksk38
提出日時 2017-07-06 19:35:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 78,472 KB
実行使用メモリ 24,420 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 01:21:33
合計ジャッジ時間 2,074 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,304 KB
testcase_01 AC 20 ms
23,604 KB
testcase_02 AC 19 ms
23,388 KB
testcase_03 AC 20 ms
23,616 KB
testcase_04 AC 21 ms
23,316 KB
testcase_05 AC 21 ms
23,400 KB
testcase_06 AC 23 ms
23,400 KB
testcase_07 AC 24 ms
23,376 KB
testcase_08 AC 20 ms
23,424 KB
testcase_09 AC 20 ms
23,832 KB
testcase_10 AC 46 ms
23,316 KB
testcase_11 AC 20 ms
23,916 KB
testcase_12 AC 26 ms
23,940 KB
testcase_13 AC 31 ms
23,676 KB
testcase_14 AC 30 ms
23,472 KB
testcase_15 AC 30 ms
24,420 KB
testcase_16 AC 20 ms
24,048 KB
testcase_17 AC 20 ms
23,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:16: warning: ‘N’ is used uninitialized in this function [-Wuninitialized]
  vector<pl> q(N);
                ^

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;


int main()
{
	int N;
	int A[110];
	bool flag = 1;
	vector<pl> q(N);
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N-1; j >= i; j--) {
			if (A[j - 1] > A[j]) {
				swap(A[j-1],A[j]);
				q.push_back({j-1,j});
				flag = 1;
			}
		}
	}

	cout << q.size() << endl;
	for (int i = 0; i < q.size(); i++) {
		cout << q[i].first << " " << q[i].second << endl;
	}

	int damy;
	cin >> damy;

	return	0;
}
0