結果
問題 |
No.326 あみだますたー
|
ユーザー |
![]() |
提出日時 | 2018-06-22 18:47:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 956 bytes |
コンパイル時間 | 1,549 ms |
コンパイル使用メモリ | 171,848 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 18:03:14 |
合計ジャッジ時間 | 5,019 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 7 WA * 19 |
ソースコード
#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<<endl #define p2(a,b) cout<<(a)<<" "<<(b)<<endl #define v2(T) vector<vector<T>> typedef long long ll; using namespace std; const ll mod= 1e9; int main(){ int N,K; int S[110],A[110]; vector<pair<int,int>> ans; cin>>N>>K; REP(i,0,N){ S[i]=i+1; } REP(i,0,K){ int x,y; cin>>x>>y; x--;y--; swap(S[x],S[y]); } REP(i,0,N) cin>>A[i]; REP(i,0,N){ RREP(j,i+1,N){ if(S[i]!=A[j]) continue; RREP(k,i+1,j+1) { swap(A[k - 1], A[k]); ans.emplace_back(k - 1, k); } } } reverse(ALL(ans)); p(ans.size()); for(auto a:ans){ p2(a.first+1, a.second+1); } return 0; }