結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー | anta |
提出日時 | 2016-07-15 22:32:26 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,201 bytes |
コンパイル時間 | 1,818 ms |
コンパイル使用メモリ | 170,608 KB |
実行使用メモリ | 24,420 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2023-09-23 11:02:48 |
合計ジャッジ時間 | 4,693 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
23,832 KB |
testcase_01 | WA | - |
testcase_02 | AC | 26 ms
23,304 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 25 ms
23,316 KB |
testcase_10 | AC | 43 ms
23,916 KB |
testcase_11 | AC | 25 ms
23,940 KB |
testcase_12 | AC | 33 ms
23,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 25 ms
24,264 KB |
testcase_17 | AC | 26 ms
23,412 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll; template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; } template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; } struct S { int i; int x; bool operator<(S t) { return x < t.x; } }; vpii ans; void swap(S &x, S &y) { ans.emplace_back(x.i, y.i); swap(x.x, y.x); swap(x.i, y.i); } int main() { int N; while(~scanf("%d", &N)) { vector<S> A(N); for(int i = 0; i < N; ++ i) { int x; scanf("%d", &x); A[i] = { i, x }; } ans.clear(); rep(k, N) { rep(i, N - 1) if(A[i + 1] < A[i]) swap(A[i], A[i + 1]); } printf("%d\n", (int)ans.size()); for(int i = 0; i < (int)ans.size(); ++ i) printf("%d %d\n", ans[i].first, ans[i].second); fflush(stdout); int dummy; scanf("%d", &dummy); } return 0; }