换座位
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
题目描述
小明的班上有个小朋友,一开始第个小朋友坐在第个位置上。
现在经历了轮换位置,第轮,坐在第个位置上的小朋友,跟坐在第个位置上的小朋友交换了位置。
显然,模拟这个过程谁都会的,所以小明的问题比这个难一点:
一共有组询问,第组询问是这样的:
t u v id:表示的是,假设,其余不变,那么执行完轮换位置后,小朋友现在坐在哪个位置上。
注意,每次询问对后续是无影响的。
输入格式
由于数据量太大了,所以数据按照如下格式输入,含义如上所示:
int randseed,n,m,Q;
int x[maxn],y[maxn],t[maxn],u[maxn],v[maxn],id[maxn];
unsigned int rnd()
{
unsigned int r;
r = randseed = randseed * 1103515245 + 12345;
return (r << 16) | ((r >> 16) & 0xFFFF);
}
void init()
{
cin>>n>>m>>Q>>randseed;
for (int i=1;i<=m;i++) {x[i]=rnd()%n+1; y[i]=rnd()%n+1;}
for (int i=1;i<=Q;i++) {t[i]=rnd()%m+1; u[i]=rnd()%n+1; v[i]=rnd()%n+1; id[i]=rnd()%n+1;}
}
输出格式
输出模的结果。
5 5 5 114
50
样例解释 #1
实际上输入的数据是:。
原先的五次操作分别是:
2 3
5 4
1 5
5 4
2 2
对应的次查询分别是:
1 3 1 5
1 1 3 5
4 3 2 3
4 1 5 5
5 2 3 2
每次的答案分别是:5 5 3 4 2。
114 514 1919 810
104434340
数据范围
对于30%的数据:。
对于50%的数据:。
对于80%的数据:。
对于100%的数据:。
0127测试
- Status
- Done
- Rule
- IOI
- Problem
- 4
- Start at
- 2026-1-27 8:30
- End at
- 2026-1-27 11:42
- Duration
- 3.2 hour(s)
- Host
- Partic.
- 36