結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-07-15 22:46:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 716 ms |
コンパイル使用メモリ | 71,052 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2024-07-17 00:04:22 |
合計ジャッジ時間 | 2,157 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <iomanip> using namespace std; typedef pair<int, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int A[100]; for(int i = 0; i < N; i++) { cin >> A[i]; } vector<P> p; for(int i = 0; i < N - 1; i++) { for(int j = N - 1; j > i; j--) { if(A[j - 1] > A[j]) { p.push_back(P(j - 1, j)); swap(A[j - 1], A[j]); } } } cout << p.size() << endl; cout.flush(); for(int i = 0; i < p.size(); i++) { cout << p[i].first << " " << p[i].second << endl; cout.flush(); } cin >> N; }