QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#419014#5113. Bridgexqbf#TL 1ms5972kbC++141.6kb2024-05-23 17:00:232024-05-23 17:00:24

Judging History

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

  • [2024-05-23 17:00:24]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5972kb
  • [2024-05-23 17:00:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int len=155;
int n,m,q;
struct operation{
	int op,a,b,id,pos;
}a[maxn],b[maxn];

bool cmp(operation a,operation b){
	return a.b<b.b;
}
using pii = pair<int,int>;
struct Block{
	vector <int> vec;
	set <pii> S;
	unordered_map <int, int> trans, idx;
	void insert(int p, int t){ // swap(p, p + 1) at time t
		S.insert(make_pair(t, p));
		for (auto item : S){
			int p = item.second;
			trans[p] = p;
			trans[p + 1] = p + 1;
		}
		for (auto item : S){
			int p = item.second;
			swap(trans[p], trans[p + 1]);
		}
		for (auto item : trans)
			idx[item.second] = item.first;
	}
	int transfer(int x){
		if (idx.find(x) == idx.end())
			return x;
		return idx[x];
	}
}bk[1005];

int tmp[maxn];
signed main(){
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m>>q;
	int cnt=0;
	for(int i=0;i<q;i++){
		cin>>a[i].op;
		a[i].id=i;
		if(a[i].op==1){
			cin>>a[i].a>>a[i].b;
			b[cnt]=a[i];
			cnt++;
		}
		else{
			cin>>a[i].a;
		}
	}
	sort(b,b+cnt,cmp);
	cnt--;
	int len=200;
	int mx=0;
	for(int i=0;i<=cnt;i++){
		int id=b[i].id;
		a[id].pos=cnt/len;
		mx=max(mx,cnt/len);
	}
	
	for(int i=0;i<q;i++){
		if(a[i].op==1){
//			printf("insert: %d %d\n",a[i].a,a[i].b);
			int pos=a[i].pos;
			bk[pos].insert(a[i].a,a[i].b);
			
		}
		else{
			int x=a[i].a;
			for(int i=0;i<=mx;i++){
				x=bk[i].transfer(x);
			}
			printf("%d\n",x);
		}
	}
	return 0;
}
/*
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

*/

詳細信息

Test #1:

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

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
Time Limit Exceeded

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: