QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#419014 | #5113. Bridge | xqbf# | TL | 1ms | 5972kb | C++14 | 1.6kb | 2024-05-23 17:00:23 | 2024-05-23 17:00:24 |
Judging History
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 ...