QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#535586 | #5113. Bridge | silver_muse | WA | 387ms | 12208kb | C++20 | 849b | 2024-08-28 10:41:40 | 2024-08-28 10:41:41 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define endl '\n'
#define ph push_back
using namespace std;
const int N=1e5+5,lim=800;
int n,m,q;
int go[N][lim+5];
map<int,int>fa[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n>>m>>q;
for(int i=1;i<=n;i++)
for(int j=0;j<=lim;j++) go[i][j]=i;
int B=(m+lim-1)/lim;
while(q--)
{
int op,x,y;
cin>>op;
if(op==1)
{
cin>>x>>y;
int u=x,v=x+1;
fa[u][y]=v; fa[v][y]=u;
for(int i=y;i>=y/B*B+1;i--)
{
if(fa[u].find(i)!=fa[u].end()) u=fa[u][i];
if(fa[v].find(i)!=fa[v].end()) v=fa[v][i];
}
swap(go[u][y/B],go[v][y/B]);
}
else
{
cin>>x;
for(int i=0;i<=m/B;i++) x=go[x][i];
cout<<x<<endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 8412kb
input:
3 4 13 2 2 1 1 3 2 1 2 2 2 3 1 2 4 2 1 2 2 2 3 1 2 1 2 1 2 2 2 3
output:
2 2 1 3 3 1 2 3 2 1
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 387ms
memory: 12208kb
input:
3 100000 99997 2 2 2 2 2 3 2 3 2 3 2 3 2 3 1 2 11047 1 1 98732 1 2 90045 1 1 43556 2 1 2 3 1 2 17242 1 1 17027 2 1 1 1 94195 2 1 2 2 2 1 2 3 1 1 34124 1 2 14354 1 2 673 1 2 39812 1 2 35520 1 2 16046 2 3 2 2 1 1 25410 2 3 2 1 2 3 2 2 1 2 55684 2 1 1 2 24811 1 2 92268 1 2 60268 2 2 1 1 89272 1 2 19232...
output:
2 2 3 3 3 3 3 3 2 1 2 1 2 3 3 1 1 2 1 3 3 2 1 3 2 1 2 1 2 2 2 2 1 1 2 1 3 2 1 3 2 1 3 2 2 1 3 3 2 3 2 3 1 2 1 1 2 3 2 1 3 2 3 2 3 2 2 1 1 2 1 1 2 3 2 1 1 3 1 1 2 2 3 2 2 1 1 1 2 3 3 1 1 2 1 1 3 1 3 2 3 2 3 2 2 2 3 3 2 2 2 3 3 2 2 2 3 1 2 1 1 3 2 3 2 2 2 1 1 1 3 3 3 2 1 1 3 3 3 1 1 2 3 2 3 3 3 3 2 3 ...
result:
wrong answer 700th numbers differ - expected: '3', found: '2'