結果
| 問題 | No.3617 Swap |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-06 15:44:19 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 7,129 bytes |
| 記録 | |
| コンパイル時間 | 4,971 ms |
| コンパイル使用メモリ | 395,212 KB |
| 実行使用メモリ | 112,964 KB |
| 最終ジャッジ日時 | 2026-08-06 15:44:39 |
| 合計ジャッジ時間 | 18,009 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | AC * 3 WA * 1 |
| 小課題1 | 5 % | AC * 3 |
| 小課題2 | 5 % | AC * 5 |
| 小課題3 | 15 % | AC * 14 |
| 小課題4 | 20 % | AC * 21 |
| 小課題5 | 25 % | WA * 8 |
| 小課題6 | 10 % | WA * 8 |
| 小課題7 | 20 % | AC * 29 WA * 27 |
| 合計 | 3 * 45% = 135 点 |
ソースコード
//眠いので続きはあしたやります
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
#include <map>
#include<set>
#include<queue>
#include<stack>
#include <unordered_set>
#include<thread>
#include<bits/stdc++.h>
#include <numbers>
#include<chrono>
#include <atcoder/all>
#include <cstdio>
// #pragma GCC target("avx")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
//if(a < 0 || h <= a || b < 0 || w <= b)return;
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using mint = modint998244353;
//using mint = modint1000000007;
using mint1 = modint1000000007;
using VL = vector<ll>;
template<typename T> using pq = priority_queue<T>;//降順?(最大取り出し)
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;//昇順?(最小取り出し)
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector<vector<T>>>;
template<typename T> using vector4 = vector<vector<vector<vector<T>>>>;
template<typename T> using vector5 = vector<vector<vector<vector<vector<T>>>>>;
template<typename T> using vector6 = vector<vector<vector<vector<vector<vector<T>>>>>>;
template<typename T> using pairs = pair<T,T>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define rep1(i,n) for(ll i = 1;i <= ll(n);i++)
#define repm(i, m, n) for (int i = (m); (i) < int(n);(i)++)
#define repmr(i, m, n) for (int i = (m) - 1; (i) >= int(n);(i)--)
#define rep0(i,n) for(int i = n - 1;i >= 0;i--)
#define rep01(i,n) for(int i = n;i >= 1;i--)
// NのK乗根N < 2^64, K <= 64
uint64_t kth_root(uint64_t N, uint64_t K) {
assert(K >= 1);
if (N <= 1 || K == 1) return N;
if (K >= 64) return 1;
if (N == uint64_t(-1)) --N;
auto mul = [&](uint64_t x, uint64_t y) -> uint64_t {
if (x < UINT_MAX && y < UINT_MAX) return x * y;
if (x == uint64_t(-1) || y == uint64_t(-1)) return uint64_t(-1);
return (x <= uint64_t(-1) / y ? x * y : uint64_t(-1));
};
auto power = [&](uint64_t x, uint64_t k) -> uint64_t {
if (k == 0) return 1ULL;
uint64_t res = 1ULL;
while (k) {
if (k & 1) res = mul(res, x);
x = mul(x, x);
k >>= 1;
}
return res;
};
uint64_t res;
if (K == 2) res = sqrtl(N) - 1;
else if (K == 3) res = cbrt(N) - 1;
else res = pow(N, nextafter(1 / double(K), 0));
while (power(res + 1, K) <= N) ++res;
return res;
}
// ユークリッドの互除法による最大公約数算出
ll GCD(ll a,ll b){
if(b == 0)return a;
return GCD(b, a % b);
}
//拡張ユークリッドの互除法による(ax + by = GCD(a,b))を満たすx,yの算出
pair<long long, long long> extgcd(long long a, long long b) {
if (b == 0) return make_pair(1, 0);
long long x, y;
tie(y, x) = extgcd(b, a % b);
y -= a / b * x;
return make_pair(x, y);
}
struct UnionFind {
int n;
vector<int> parent;
vector<int> size;
UnionFind(int n) : n(n), parent(n), size(n, 1) {
for (int i = 0; i < n; i++) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) return x;
return parent[x] = root(parent[x]);
}
bool unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y) return false;
if (size[x] < size[y]) swap(x, y);
parent[y] = x;
size[x] += size[y];
return true;
}
bool same(int x, int y) { return root(x) == root(y); }
};
//座標圧縮
vector<ll> Ccomp(vector<ll> a){
vector<ll> b = a;
sort(b.begin(),b.end());
b.erase(unique(b.begin(),b.end()),b.end());//ダブり消去
vector<ll> rtn;
rep(j,a.size()){
ll pb = lower_bound(b.begin(),b.end(),a[j]) - b.begin();
rtn.push_back(pb);
}
return rtn;
}
string abc = "abcdefghijklmnopqrstuvwxyz";
string Labc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll INF = ll((1LL<<61)+1);
ll mod = 998244353;
ll mod1 = ll(1e9) + 7;
int inf = int(1e9+10);
vector<ll> movey = {-1,0,1,0,-1,-1,1,1},movex = {0,1,0,-1,-1,1,-1,1};
bool outc(ll nowy,ll nowx,ll h,ll w){
if(nowy < 0 || nowy >= h || nowx < 0 || nowx >= w){
return 0;
}
return 1;
}
vector<mint> vecfact(2,1);
mint fact(ll x){
if(x >= 500 + vecfact.size()){
fact(x-500);
}
if(x >= vecfact.size()){
mint get = fact(x-1);
vecfact.push_back(get * x);
}
return vecfact[x];
}
ll maxim = 200000;
vector<ll> bitprimes = {999999929,999999937,1000000021,1000000033,1000000087,1000000093,1000000097};
using mint9 = modint;
ll mod9 = bitprimes[rand() % 7];
/// ここから////////////////////////////////////////////
using F = ll;
using S = array<ll,10>;
string s;
ll modPow(ll a, ll n, ll mod) { if(mod==1) return 0;ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
void cincout(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout<< fixed << setprecision(15);
}
//seg,遅延segの設定-----ここから
S op(S a,S b){
array<ll,20> c;
rep(j,10)c[j] = a[j];
rep(j,10)c[10+j] = b[j];
sort(c.begin(),c.end());
array<ll,10> d;
rep(j,10)d[j] = c[j];
return d;
}
S e(){
array<ll,10> rt;
rep(j,10)rt[j] = INF;
return rt;
};
// S opb(S a,S b){
// return max(a,b);
// }
// S eb(){return -INF;};
// S mapping (F a,S b){
// return a + b;
// }//遅延処理
// F composition (F a,F b){
// return a + b;
// }//遅延中の枝にさらに処理
// F id(){return 0;}//遅延のモノイド
// using LST= lazy_segtree<S,op,e,F,mapping,composition,id>;
using ST = segtree<S,op,e>;
//segここまで
mint ncr(ll n,ll r){
return fact(n)/fact(r)/fact(n-r);
}
void solve() {
ll n,m,q;
cin >> n >> m >> q;
vector<array<ll,2>> lr(m);
rep(j,m){
cin >> lr[j][0] >> lr[j][1];
lr[j][0]--,lr[j][1]--;
}
vector<ll> a(n);
rep(j,n)a[j] = j;
vector<array<ll,2>> t(q);
rep(j,q){
cin >> t[j][0] >> t[j][1];
t[j][1]--;
}
rep(j,m){
swap(a[lr[j][0]],a[lr[j][1]]);
}
vector b(61,vector<ll>(n));
vector d(61,vector<ll>(n));
rep(j,n)b[0][j] = a[j];
rep1(j,60){
rep(i,n){
b[j][i] = b[j-1][b[j-1][i]];
d[j][b[j][i]] = i;
}
}
rep(j,q){
ll get = t[j][0]/m;
rep(i,61){
if(get&(1ll<<i)){
t[j][1] = b[i][t[j][1]];
}
}
}
vector<array<ll,3>> tt(q);
rep(j,q){
tt[j][0] = t[j][0]%m;
tt[j][1] = t[j][1];
tt[j][2] = j;
}
sort(tt.begin(),tt.end());
ll now = 0;
vector<ll> ans(q);
rep(j,n)a[j] = j;
rep(j,q){
while(now<tt[j][0]){
swap(a[lr[now][0]],a[lr[now][1]]);
now++;
}
ans[tt[j][2]] = a[tt[j][1]];
}
rep(j,q){
cout << ans[j]+1 << endl;
}
return;
}
signed main() {
cincout();
ll t;
t = 1;
// cin >> t;
rep(tt,t)solve();
return 0;
};