QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217263#5113. Bridgeucup-team1001WA 97ms15776kbC++202.4kb2023-10-16 17:51:292023-10-16 17:51:29

Judging History

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

  • [2023-10-16 17:51:29]
  • 评测
  • 测评结果:WA
  • 用时:97ms
  • 内存:15776kb
  • [2023-10-16 17:51:29]
  • 提交

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 = 370;
const int K = N / len + 50;
int per[N][655],invp[N][655];


struct stak{
	int tot;
	int opt[1005][2];
	stak(){tot = 0;}
	void push(int x,int y){
		opt[++ tot][0] = x, opt[tot][1] = y;
	}
	void top(int &x, int &y){
		x = opt[tot][0], y = opt[tot][1];
	}
	void pop(){
		-- tot;
	}
	int size(){
		return tot;
	}
};

stak p[1055];

// 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();
	vector<array<int,2>>quests(q);
	vector<array<int,2>>bd;

	irep(i, 0, q - 1){
		if(read() == 1){
			int line = read(), cloumn = read();
			quests[i] = {cloumn, line};
			bd.push_back({cloumn, line});
		}
		else
		{
			int pos = read();
			quests[i] = {pos, -1};
		}
	}
	sort(bd.begin(), bd.end());
	
	for(int c = 0; c <= bd.size() / len; c ++){
		for(int i = 1; i <= n; ++ i){
			per[i][c] = invp[i][c] = i;
		}
	}
	//return 0;
	irep(ii, 0, q - 1){
		//int op = read();
		if(quests[ii][1] != -1){
			auto [cloumn, line] = quests[ii];

			array<int, 2>arr = {cloumn, line};
			int x = lower_bound(bd.begin(), bd.end(), arr) - bd.begin();
			x /= len;
//			array<int, 2> PI = {cloumn, line};
			stak temp;
			
			while(p[x].size()){
				int c, l;
				p[x].top(c, l);
//				auto [c, l] = p[x].top();
				if(c < cloumn)break;
				int tx, ty;
				p[x].top(tx, ty);
//				temp.push(p[x].top());
				temp.push(tx, ty);
				
				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(cloumn, line);
			
			while(temp.size()){
				int c, l;
				temp.top(c, l);
				
				per[invp[l][x]][x] = l + 1;
				per[invp[l + 1][x]][x] = l;
				swap(invp[l][x], invp[l + 1][x]);
				int tx, ty;
				temp.top(tx, ty);
//				temp.push(p[x].top());
				p[x].push(tx, ty);
				
				temp.pop();
			}
		}
		else{
			int a = quests[ii][0];
			for(int x = 0; x <= m / len; ++ x){
				a = per[a][x];
			}
			cout << a << '\n';
		}
	}
}

詳細信息

Test #1:

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

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: 97ms
memory: 15776kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st numbers differ - expected: '2', found: '0'