QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214576#5113. Bridgeucup-team1001WA 172ms162776kbC++201.5kb2023-10-14 21:24:252023-10-14 21:24:25

Judging History

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

  • [2023-10-14 21:24:25]
  • 评测
  • 测评结果:WA
  • 用时:172ms
  • 内存:162776kb
  • [2023-10-14 21:24:25]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define irep(i,l,r) for(int i = l; i <= r; ++ i)

const int N = 100099;
const int len = 253;

int per[N][400],invp[N][400],  id[N];
vector<array<int, 2>>p[400];
// clo, line
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m, q;
	cin >> n >> m >> q;
	memset(per, 1, sizeof(per));
	for(int i = 1; i <= m; ++ i){
		id[i] = i / len;
	}
	
	for(int c = 0; c <= m / len; c ++){
		for(int i = 1; i <= n; ++ i){
			per[i][c] = invp[i][c] = i;
		}
	}
	while(q --){
		int op;
		cin >> op;
		if(op == 1){
			int line, cloumn;
			cin >> line >> cloumn;
			int x = id[cloumn];
			array<int, 2> PI = {cloumn, line};
			vector<array<int, 2>>temp;
			
			while(p[x].size()){
				auto [c, l] = p[x].back();
				if(c < cloumn)break;
				temp.push_back(p[x].back());
			//	swap(per[l][x], per[l + 1][x]);
				per[invp[l][x]][x] = l + 1;
				per[invp[l + 1][x]][x] = l;
				swap(invp[l], invp[l + 1]);
				/*
				A -> per[A][x]
				
				*/
				p[x].pop_back();
			}
			temp.push_back(PI);
			
			while(temp.size()){
				auto [c, l] = temp.back();
	//			swap(per[l][x], per[l + 1][x]);
				per[invp[l][x]][x] = l + 1;
				per[invp[l + 1][x]][x] = l;
				swap(invp[l], invp[l + 1]);
				p[x].push_back(temp.back());
				temp.pop_back();
			}
		//	irep(i, 1, n){
		//		cerr << per[i][0] << ' ';
		//	}
		//	cerr << endl;
		}
		else{
			int a;
			cin >> a;
			for(int x = 0; x <= m / len; ++ x){
				a = per[a][x];
			}
			cout << a << endl;
		}
	}
}

详细

Test #1:

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

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: 172ms
memory: 162400kb

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
1
1
1
1
2
1
1
2
1
2
2
2
1
2
1
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

wrong answer 8th numbers differ - expected: '3', found: '1'