Submission #11226932


Source Code Expand

#include<bits/stdc++.h>
#define inf ((1<<30)-1)
#define linf ((1<<62)ll-1)
#define LL long long
#define F(i,a,b,c) for(register int i=(a);(b);i=(c))
#define Fu(i,a,b) for(register int i=(a);i<=(b);++i)
#define Fd(i,a,b) for(register int i=(a);i>=(b);--i)
#define Fn(i,a) for(register int i=las[(a)];i;i=nex[i])
#define COND(c) (isprint(c))
int Fl,Pn,SI=100;char mch=' ',ch,Bf[21];
void chin(char&c){while(!COND(c=getchar()));}
template<typename t>void in(t&a){a=0;ch=getchar();Fl=1;while(((ch<'0')||(ch>'9'))&&ch!=EOF)Fl=(ch=='-')?-Fl:Fl,ch=getchar();while((ch>='0')&&(ch<='9'))a=a*10+ch-'0',ch=getchar();a*=Fl;}template<typename t>void out(t a){if(a<0)putchar('-'),a=-a;if(a==0)putchar('0');while(a)Bf[++Pn]=a%10+'0',a/=10;while(Pn)putchar(Bf[Pn]),--Pn;putchar(mch);}
template<typename t,typename ...ARGS>void in(t&a,ARGS&...args){in(a);in(args...);}
template<typename t,typename ...ARGS>void out(t a,ARGS... args){out(a);out(args...);}
using namespace std;
int n,m,f[(int)1e5+1],t1,t2,t3;
int getf(int x)
{
	if(f[x]==x)return x;
	return f[x]=getf(f[x]);
}
int main()
{
	in(n,m);
	Fu(i,1,n)f[i]=i;
	Fu(i,1,m)
	{
		in(t1,t2,t3);
		if(t1==0)f[getf(t3)]=getf(t2);
		else puts((getf(t2)==getf(t3))?"Yes":"No");
	}
	return 0;
}
//BY Segment_Tree_Juruo (2020严誉沣)

Submission Info

Submission Time
Task B - Union Find
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 100
Code Size 1298 Byte
Status AC
Exec Time 31 ms
Memory 1280 KB

Compile Error

./Main.cpp:13:30: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 template<typename t,typename ...ARGS>void in(t&a,ARGS&...args){in(a);in(args...);}
                              ^
./Main.cpp:13:58: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 template<typename t,typename ...ARGS>void in(t&a,ARGS&...args){in(a);in(args...);}
                                                          ^
./Main.cpp:14:30: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 template<typename t,typename ...ARGS>void out(t a,ARGS... args){out(a);out(args...);}
                              ^
./Main.cpp:14:59: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 template<typename t,typename ...ARGS>void out(t a,ARGS... args){out(a);out(args...);}
                                                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 1
AC × 19
Set Name Test Cases
Sample 00_sample_01.txt
All 00_sample_01.txt, subtask_01_01.txt, subtask_01_02.txt, subtask_01_03.txt, subtask_01_04.txt, subtask_01_05.txt, subtask_01_06.txt, subtask_01_07.txt, subtask_01_08.txt, subtask_01_09.txt, subtask_01_10.txt, subtask_01_11.txt, subtask_01_12.txt, subtask_01_13.txt, subtask_01_14.txt, subtask_01_15.txt, subtask_01_16.txt, subtask_01_17.txt, subtask_01_18.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 256 KB
subtask_01_01.txt AC 15 ms 640 KB
subtask_01_02.txt AC 1 ms 640 KB
subtask_01_03.txt AC 15 ms 1024 KB
subtask_01_04.txt AC 28 ms 1152 KB
subtask_01_05.txt AC 2 ms 256 KB
subtask_01_06.txt AC 3 ms 640 KB
subtask_01_07.txt AC 21 ms 896 KB
subtask_01_08.txt AC 28 ms 1280 KB
subtask_01_09.txt AC 1 ms 256 KB
subtask_01_10.txt AC 1 ms 640 KB
subtask_01_11.txt AC 16 ms 896 KB
subtask_01_12.txt AC 28 ms 1280 KB
subtask_01_13.txt AC 19 ms 768 KB
subtask_01_14.txt AC 1 ms 640 KB
subtask_01_15.txt AC 18 ms 896 KB
subtask_01_16.txt AC 28 ms 1152 KB
subtask_01_17.txt AC 26 ms 896 KB
subtask_01_18.txt AC 31 ms 896 KB