QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355276#5110. Splitstreamucup-team052#WA 1ms3836kbC++231.3kb2024-03-16 15:11:142024-03-16 15:11:14

Judging History

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

  • [2024-03-16 15:11:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3836kb
  • [2024-03-16 15:11:14]
  • 提交

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;
		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: 1ms
memory: 3836kb

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:

none
none
none
none
none
none
1
3
none
none
none
none
4
none
2
none
none
none
none
none
none
none
none
4
none
none

result:

wrong answer 1st lines differ - expected: '5', found: 'none'