Submission #64087579


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
struct b{
int u,v;
}s[105];
int hade[105],jl[105],sl[3],bzt[105][105];
int cmp(b p1,b p2){
return p1.u<p2.u;
}
void dfs(int wz,int zt,int syg){
sl[zt]++;
jl[wz]=zt;
for(int i=hade[wz];s[i].u==wz;i++){
if(s[i].v!=syg)
dfs(s[i].v,3-zt,wz);
}
return ;
}
int main(){
int n,ans;
scanf("%d",&n);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
struct b{
	int u,v;
}s[105];
int hade[105],jl[105],sl[3],bzt[105][105];
int cmp(b p1,b p2){
	return p1.u<p2.u;
}
void dfs(int wz,int zt,int syg){
	sl[zt]++;
	jl[wz]=zt;
	for(int i=hade[wz];s[i].u==wz;i++){
		if(s[i].v!=syg)
			dfs(s[i].v,3-zt,wz);
	}
	return ;
}
int main(){
	int n,ans;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&s[i].u,&s[i].v);
		s[i+n-1].u=s[i].v;
		s[i+n-1].v=s[i].u;
		bzt[s[i].u][s[i].v]=1;
		bzt[s[i].v][s[i].u]=1;
	}
	sort(s,s+2*n-2,cmp);
	hade[s[0].u]=0;
	for(int i=1;i<2*n-2;i++){
		if(s[i].u!=s[i-1].u)
			hade[s[i].u]=i;
	}
	dfs(s[0].u,1,-1);
	ans=sl[1]*sl[2]-n+1;
	if(ans%2){
		printf("First\n");
		fflush(stdout);
	}else{
		int ls1,ls2;
		printf("Second\n");
		fflush(stdout);
		scanf("%d%d",&ls1,&ls2);
		if(ls1==-1&&ls2==-1)
			return 0;
		bzt[ls1][ls2]=1;
		bzt[ls2][ls1]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1,ls1,ls2;j<=n;j++){
			if(bzt[i][j]==0&&jl[i]!=jl[j]&&i!=j){
				printf("%d %d\n",i,j);
				bzt[i][j]=1;
				bzt[j][i]=1;
				fflush(stdout);
				scanf("%d%d",&ls1,&ls2);
				bzt[ls1][ls2]=1;
				bzt[ls2][ls1]=1;
				if(ls1==-1&&ls2==-1)
					return 0;
			}
		}
	}
	return 0;
}

Submission Info

Submission Time
Task E - Tree Game
User miaorunhao2
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1251 Byte
Status AC
Exec Time 96 ms
Memory 4060 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
Main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |                 scanf("%d%d",&s[i].u,&s[i].v);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |                 scanf("%d%d",&ls1,&ls2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:57:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   57 |                                 scanf("%d%d",&ls1,&ls2);
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status AC
AC × 29
Set Name Test Cases
Sample
All hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt
Case Name Status Exec Time Memory
hand_01.txt AC 3 ms 3932 KB
random_01.txt AC 94 ms 3888 KB
random_02.txt AC 96 ms 3980 KB
random_03.txt AC 95 ms 3836 KB
random_04.txt AC 91 ms 3868 KB
random_05.txt AC 95 ms 3968 KB
random_06.txt AC 96 ms 3964 KB
random_07.txt AC 96 ms 3932 KB
random_08.txt AC 93 ms 3840 KB
random_09.txt AC 3 ms 3744 KB
random_10.txt AC 90 ms 3784 KB
random_11.txt AC 3 ms 3844 KB
random_12.txt AC 88 ms 3876 KB
random_13.txt AC 88 ms 3744 KB
random_14.txt AC 89 ms 3772 KB
random_15.txt AC 87 ms 3968 KB
random_16.txt AC 88 ms 3888 KB
random_17.txt AC 95 ms 3960 KB
random_18.txt AC 94 ms 3976 KB
random_19.txt AC 92 ms 3864 KB
random_20.txt AC 94 ms 4060 KB
random_21.txt AC 89 ms 3776 KB
random_22.txt AC 85 ms 3732 KB
random_23.txt AC 3 ms 3900 KB
random_24.txt AC 84 ms 3944 KB
random_25.txt AC 86 ms 3696 KB
random_26.txt AC 92 ms 3940 KB
random_27.txt AC 93 ms 4040 KB
random_28.txt AC 86 ms 3832 KB


2025-03-30 (Sun)
15:58:18 +00:00