QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#390349 | #5113. Bridge | Soestx | TL | 14ms | 97440kb | C++14 | 1.1kb | 2024-04-15 12:39:20 | 2024-04-15 12:39:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pll pair<long long,long long>
#define fi first
#define se second
const int N=1e6+10;
const double eps=1e-5;
int n,m,k,q;
int res,cnt;
set<int> st[N];
map<int,bool> mp[N];
void dfs(int id,int pos,int dep)
{
if(dep>1e5+10) return;
auto it=upper_bound(st[id].begin(),st[id].end(),pos);
if(it==st[id].end())
{
res=id;
return;
}
// cout<<id<<" "<<pos<<" "<<f<<"------"<<*it<<endl;
int ne;
if(mp[id][*it]) ne=id+1;
else ne=id-1;
dfs(ne,*it,dep+1);
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>q;
while(q--)
{
int op,a,b;
cin>>op;
if(op==1)
{
cin>>a>>b;
st[a].insert(b);
st[a+1].insert(b);
mp[a][b]=1;
mp[a+1][b]=0;
}
else
{
cin>>a;
res=a;
dfs(a,-1,-1);
cout<<res<<endl;
}
}
}
/*
3 3=3 3
2_
2__
__1
___
*/
详细
Test #1:
score: 100
Accepted
time: 14ms
memory: 97440kb
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 ...