QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#355280 | #5110. Splitstream | ucup-team052# | WA | 0ms | 3864kb | C++23 | 1.3kb | 2024-03-16 15:12:04 | 2024-03-16 15:12:04 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=30005;
map<int,int>mp;
int idx;
int sz[N];
struct node{
char c;
int x,y,z;
};
int fr[N],fr_[N],ty[N];
int ID(int x){
if(mp.count(x)){
return mp[x];
}else{
return mp[x]=++idx;
}
}
int m,n,Q;
int ask(int u,int x){
if(u==1){
return x;
}
if(ty[u]==0){
return ask(fr[u],x*2-1);
}else if(ty[u]==1){
return ask(fr[u],x*2);
}else{
if(x>sz[fr[u]]*2-1){
return ask(fr_[u],x-sz[fr[u]]);
}else if(x>sz[fr_[u]]*2){
return ask(fr[u],x-sz[fr_[u]]);
}else if(x&1){
return ask(fr[u],(x+1)/2);
}else{
return ask(fr_[u],x/2);
}
}
}
int main(){
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
cin>>m>>n>>Q;
sz[ID(1)]=m;
rep(i,1,n){
char c;
cin>>c;
int x,y,z;
cin>>x>>y>>z;
x=ID(x),y=ID(y),z=ID(z);
if(c=='S'){
sz[y]=(sz[x]+1)/2;
fr[y]=x;
ty[y]=0;
sz[z]=sz[x]/2;
fr[z]=x;
ty[z]=1;
}else{
sz[z]=sz[x]+sz[y];
fr[z]=x,fr_[z]=y,ty[z]=2;
}
}
rep(tc,1,Q){
int x,k;
cin>>x>>k;
x=ID(x);
if(k>sz[x]){
puts("none");
}else{
printf("%d\n",ask(x,k));
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3864kb
input:
5 8 26 M 8 9 13 S 2 4 5 S 1 2 3 M 6 5 8 S 4 9 10 S 10 14 15 S 3 6 7 S 7 11 12 2 3 2 4 3 2 3 3 4 2 4 3 5 1 5 2 6 1 6 2 7 1 7 2 8 2 8 3 9 1 9 2 10 1 10 2 11 1 11 2 12 1 13 3 13 4 14 1 14 2 15 1
output:
5 none 4 none none none none none 2 none 4 none none none none none none none 4 none none none none none none none
result:
wrong answer 5th lines differ - expected: '5', found: 'none'