結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2018-03-07 03:42:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 695 ms |
コンパイル使用メモリ | 89,076 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2024-07-17 01:36:11 |
合計ジャッジ時間 | 2,237 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; struct P { P( int x, int y ) { a = x; b = y; }; int a; int b; }; int main() { int N; cin >> N; vector<int> A(N); for ( int i = 0; i < N; i++ ) { cin >> A[i]; } vector<P> V; for ( int i = 0; i < N-1; i++ ) { for ( int j = 0; j < N-1-i; j++ ) { if ( A[j] > A[j+1] ) { swap( A[j], A[j+1] ); P p(j,j+1); V.push_back(p); } } } cout << V.size() << endl; for ( auto& v : V ) { cout << v.a << " " << v.b << endl; } cin >> N; return 0; }