QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217169#5113. Bridgeucup-team1001ML 141ms6316kbC++201.5kb2023-10-16 16:10:152023-10-16 16:10:15

Judging History

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

  • [2023-10-16 16:10:15]
  • 评测
  • 测评结果:ML
  • 用时:141ms
  • 内存:6316kb
  • [2023-10-16 16:10:15]
  • 提交

answer

#include<bits/stdc++.h>
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;

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

const int N = 100099;
const int len = 153;
const int K = N / len + 50;
int per[N][800],invp[N][800];
stack<array<int, 2>>p[800];
// clo, line
inline int read(){
	char ch = getchar();
	int s = 0;
	while(!isdigit(ch))ch = getchar();
	while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return s;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n = read(), m = read(), q = read();
	
	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 = read();
		if(op == 1){
			int line = read(), cloumn = read();
			int x = cloumn / len;
			array<int, 2> PI = {cloumn, line};
			stack<array<int, 2>>temp;
			
			while(p[x].size()){
				auto [c, l] = p[x].top();
				if(c < cloumn)break;
				temp.push(p[x].top());
				per[invp[l][x]][x] = l + 1;
				per[invp[l + 1][x]][x] = l;
				swap(invp[l][x], invp[l + 1][x]);
				p[x].pop();
			}
			temp.push(PI);
			
			while(temp.size()){
				auto [c, l] = temp.top();
				per[invp[l][x]][x] = l + 1;
				per[invp[l + 1][x]][x] = l;
				swap(invp[l][x], invp[l + 1][x]);
				p[x].push(temp.top());
				temp.pop();
			}
		}
		else{
			int a = read();
//			cin >> a;
			for(int x = 0; x <= m / len; ++ x){
				a = per[a][x];
			}
			cout << a << endl;
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6212kb

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: 0
Accepted
time: 141ms
memory: 6316kb

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:

ok 60761 numbers

Test #3:

score: -100
Memory Limit Exceeded

input:

100000 5 20
1 40277 1
2 55431
2 22404
2 29137
2 10206
2 72758
2 92880
1 96104 2
2 12641
1 99618 2
2 88481
1 76531 3
1 91957 5
1 23999 2
2 35922
1 69730 5
1 16353 2
1 90312 1
1 75264 5
2 77283

output:

55431
22404
29137
10206
72758
92880
12641
88481
35922
77283

result: