QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#535590#5113. Bridgesilver_museWA 379ms12200kbC++20891b2024-08-28 10:47:502024-08-28 10:47:50

Judging History

你现在查看的是最新测评结果

  • [2024-08-28 10:47:50]
  • 评测
  • 测评结果:WA
  • 用时:379ms
  • 内存:12200kb
  • [2024-08-28 10:47:50]
  • 提交

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;
    		//if(y==m+1) continue;
    		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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 9980kb

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: 379ms
memory: 12200kb

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 776th numbers differ - expected: '2', found: '3'