結果
問題 | No.326 あみだますたー |
ユーザー | kotatsugame |
提出日時 | 2019-10-12 16:44:45 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 591 bytes |
コンパイル時間 | 678 ms |
コンパイル使用メモリ | 71,160 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-06 01:52:00 |
合計ジャッジ時間 | 6,742 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 4 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 9 ms
5,376 KB |
testcase_09 | AC | 10 ms
5,376 KB |
testcase_10 | AC | 11 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> using namespace std; int N,K; int A[100],invA[100]; int p[100]; vector<pair<int,int> >ans; main() { cin>>N>>K; for(int i=0;i<N;i++)p[i]=i; for(int i=0;i<K;i++) { int u,v;cin>>u>>v; u--,v--; p[u]^=p[v]^=p[u]^=p[v]; } for(int i=0;i<N;i++) { cin>>A[i]; A[i]--; invA[A[i]]=i; } for(int i=0;i<N;i++) { for(int j=0;j<N-i-1;j++) { if(invA[p[j]]>invA[p[j+1]]) { ans.push_back(make_pair(j+1,j+2)); p[j]^=p[j+1]^=p[j]^=p[j+1]; } } } cout<<ans.size()<<endl; for(pair<int,int>p:ans)cout<<p.first<<" "<<p.second<<endl; }