結果
問題 | No.326 あみだますたー |
ユーザー | cormoran |
提出日時 | 2016-06-28 17:53:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,842 bytes |
コンパイル時間 | 620 ms |
コンパイル使用メモリ | 79,152 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-20 04:34:08 |
合計ジャッジ時間 | 4,005 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 8 ms
5,376 KB |
testcase_09 | AC | 8 ms
5,376 KB |
testcase_10 | AC | 8 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 | - |
ソースコード
#include<iostream> #include<vector> #include<cassert> #include<string> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cmath> #include<stack> #include<queue> #include<set> #include<map> #include<tuple> #include<numeric> using namespace std; using pii = pair<int,int>; using ll = long long; #define rep(i, j) for(int i=0; i < (int)(j); i++) #define repeat(i, j, k) for(int i = (j); i < (int)(k); i++) #define all(v) v.begin(),v.end() #define debug(x) cerr << #x << " : " << x << endl // vector template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; } template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; } // pair template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << " " << v.second << ">"; } bool solve() { int N, K; cin >> N >> K; vector<int> X(K); rep(i, K) { int y; cin >> X[i] >> y; X[i]--; } vector<int> A(N); cin >> A; rep(i, N) A[i]--; vector<int> bar(N); rep(i, N) bar[i] = i; rep(i, K) swap(bar[X[i]], bar[X[i] + 1]); // debug(bar); vector<int> ans; rep(i, N) { // iを合わせる vector<int> tmp; repeat(j, i, N) if(A[i] == bar[j]) { for(int k = j - 1; k >= i; k--) { swap(bar[k + 1], bar[k]); tmp.push_back(k); } break; } ans.insert(ans.end(), all(tmp)); } // debug(bar); cout << ans.size() << endl; for(int a : ans) { cout << a + 1 << " " << a + 2 << endl; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); while(solve()); return 0; }