QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217166#5113. Bridgeucup-team1001RE 1ms5892kbC++201.5kb2023-10-16 16:09:362023-10-16 16:09:37

Judging History

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

  • [2023-10-16 16:09:37]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5892kb
  • [2023-10-16 16:09:36]
  • 提交

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[400];
// 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;
		}
	}
}

詳細信息

Test #1:

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

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
Runtime Error

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

result: