結果
問題 | No.2002 Range Swap Query |
ユーザー | otoshigo |
提出日時 | 2023-12-09 18:34:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 908 ms |
コンパイル使用メモリ | 87,752 KB |
実行使用メモリ | 26,532 KB |
最終ジャッジ日時 | 2023-12-09 18:34:31 |
合計ジャッジ時間 | 5,291 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 1 ms
6,676 KB |
testcase_04 | AC | 2 ms
6,676 KB |
testcase_05 | AC | 2 ms
6,676 KB |
testcase_06 | AC | 2 ms
6,676 KB |
testcase_07 | AC | 2 ms
6,676 KB |
testcase_08 | AC | 4 ms
6,676 KB |
testcase_09 | AC | 5 ms
6,676 KB |
testcase_10 | AC | 3 ms
6,676 KB |
testcase_11 | AC | 4 ms
6,676 KB |
testcase_12 | AC | 224 ms
26,532 KB |
testcase_13 | AC | 211 ms
26,532 KB |
testcase_14 | AC | 221 ms
26,532 KB |
testcase_15 | AC | 198 ms
25,764 KB |
testcase_16 | AC | 115 ms
21,540 KB |
testcase_17 | AC | 234 ms
26,532 KB |
testcase_18 | AC | 90 ms
9,856 KB |
testcase_19 | AC | 163 ms
23,460 KB |
testcase_20 | AC | 72 ms
11,136 KB |
testcase_21 | AC | 58 ms
8,192 KB |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<tuple> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,K,Q; cin>>N>>K>>Q; vector<int>A(K),B(K); for(int i=0;i<K;i++){ cin>>A[i]>>B[i]; A[i]--; B[i]--; } vector<vector<pair<int,int>>>vp(K); vector<vector<int>>vs(K); for(int i=0;i<Q;i++){ int l,r,x; cin>>l>>r>>x; l--; r--; x--; vp[r].push_back(make_pair(x,i)); vs[l].push_back(i); } vector<int>P(N),at(N),V(Q,-1); for(int i=0;i<N;i++){ P[i]=i; at[i]=i; } vector<int>ans(Q); for(int i=K-1;i>=0;i--){ for(auto[x,q]:vp[i]){ V[q]=P[x]; } swap(P[A[i]],P[B[i]]); swap(at[P[A[i]]],at[P[B[i]]]); for(auto q:vs[i]){ ans[q]=at[V[q]]; } } for(int i=0;i<Q;i++)cout<<ans[i]+1<<"\n"; }