Submission #41951530
Source Code Expand
/*
hmz is the most cute girl in this world!
--------------------------------------------
You've got to have faith
Don't let them cut you down cut you down once more
*/
#include<bits/stdc++.h>
using namespace std;
#define TY int
#define IL inline
#define umap unordered_map
#define ull unsigned long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define mod (TY)(1e9+7)
#define MAXN 200005
#define MAXM 200005
#define MAXK 27
#define INF (TY)(1e9)
#define block 300
#define For(i,a,b) for(TY i=(a);i<=(b);++i)
#define FOR(i,a,b) for(TY i=(a);i<(b);++i)
#define Rof(i,a,b) for(TY i=(a);i>=(b);--i)
#define ROF(i,a,b) for(TY i=(a);i>(b);--i)
IL TY qr(){
TY x=0,f=1;char op=getchar();
for(;op<'0'||op>'9';op=getchar())if(op=='-')f=-1;
for(;op>='0'&&op<='9';op=getchar())x=x*10+(op^48);
return x*f;
}IL bool ischar(char op){
if(op>='a'&&op<='z')return true;
if(op>='A'&&op<='Z')return true;
return false;
}IL char getc(){
char op=getchar();
while(!ischar(op))op=getchar();
return op;
}IL string qs(){
string op="";char u=getchar();
while(!ischar(u))u=getchar();
while(ischar(u))op+=u,u=getchar();
return op;
}IL void qw(TY x){
if(!x){putchar('0');return;}
if(x<0)putchar('-'),x=-x;
if(x>=10)qw(x/10);putchar(x%10+'0');
}IL void qw(TY x,char op){qw(x),putchar(op);}
IL void ws(string s){FOR(i,0,s.size())putchar(s[i]);}
IL TY Ceil(TY a,TY b){return a/b+(a%b!=0);}
IL TY Mod(TY a){return (a>=mod?a-mod:a);}
IL TY Abs(TY a,TY b){return a>b?a-b:b-a;}
IL TY Pow(TY a,TY b){
TY ans=1,base=a;
while(b){
if(b&1)ans=ans*base%mod;
base=base*base%mod;b>>=1;
}return ans;
}TY n,m,k,q,fa[MAXN];
map<TY,bool> have[MAXN];
IL TY getfa(TY now){
if(now==fa[now])return now;
else{
fa[now]=getfa(fa[now]);
return fa[now];
}
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=qr();m=qr();
For(i,1,n)fa[i]=i;
For(i,1,m){
TY u=qr(),v=qr();
fa[getfa(u)]=getfa(v);
}k=qr();For(i,1,k){
TY u=qr(),v=qr();
have[getfa(u)][getfa(v)]=have[getfa(v)][getfa(u)]=1;
}
/* init */
q=qr();For(i,1,q){
TY u=qr(),v=qr();
if(!have[getfa(u)][getfa(v)])puts("Yes");
else puts("No");
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Good Graph |
| User | hmzqwq |
| Language | C++ (GCC 9.2.1) |
| Score | 475 |
| Code Size | 2251 Byte |
| Status | AC |
| Exec Time | 408 ms |
| Memory | 41864 KiB |
Compile Error
./Main.cpp: In function ‘void qw(int)’:
./Main.cpp:47:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
47 | if(x>=10)qw(x/10);putchar(x%10+'0');
| ^~
./Main.cpp:47:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
47 | if(x>=10)qw(x/10);putchar(x%10+'0');
| ^~~~~~~
./Main.cpp: In function ‘void ws(std::string)’:
./Main.cpp:23:34: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
23 | #define FOR(i,a,b) for(TY i=(a);i<(b);++i)
| ^
./Main.cpp:49:22: note: in expansion of macro ‘FOR’
49 | IL void ws(string s){FOR(i,0,s.size())putchar(s[i]);}
| ^~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 475 / 475 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, example0.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 262 ms | 41756 KiB |
| 001.txt | AC | 63 ms | 13656 KiB |
| 002.txt | AC | 328 ms | 32356 KiB |
| 003.txt | AC | 21 ms | 12972 KiB |
| 004.txt | AC | 150 ms | 32472 KiB |
| 005.txt | AC | 188 ms | 31736 KiB |
| 006.txt | AC | 56 ms | 12972 KiB |
| 007.txt | AC | 67 ms | 14816 KiB |
| 008.txt | AC | 111 ms | 15768 KiB |
| 009.txt | AC | 178 ms | 31204 KiB |
| 010.txt | AC | 51 ms | 13684 KiB |
| 011.txt | AC | 62 ms | 13644 KiB |
| 012.txt | AC | 66 ms | 13640 KiB |
| 013.txt | AC | 53 ms | 13740 KiB |
| 014.txt | AC | 64 ms | 13744 KiB |
| 015.txt | AC | 70 ms | 13692 KiB |
| 016.txt | AC | 54 ms | 13744 KiB |
| 017.txt | AC | 58 ms | 13744 KiB |
| 018.txt | AC | 72 ms | 13572 KiB |
| 019.txt | AC | 56 ms | 13580 KiB |
| 020.txt | AC | 75 ms | 13700 KiB |
| 021.txt | AC | 74 ms | 13632 KiB |
| 022.txt | AC | 60 ms | 13724 KiB |
| 023.txt | AC | 73 ms | 13728 KiB |
| 024.txt | AC | 80 ms | 13536 KiB |
| 025.txt | AC | 64 ms | 13756 KiB |
| 026.txt | AC | 66 ms | 13668 KiB |
| 027.txt | AC | 91 ms | 13624 KiB |
| 028.txt | AC | 66 ms | 13848 KiB |
| 029.txt | AC | 109 ms | 14304 KiB |
| 030.txt | AC | 118 ms | 14328 KiB |
| 031.txt | AC | 81 ms | 15628 KiB |
| 032.txt | AC | 118 ms | 16460 KiB |
| 033.txt | AC | 157 ms | 16556 KiB |
| 034.txt | AC | 92 ms | 17864 KiB |
| 035.txt | AC | 113 ms | 18332 KiB |
| 036.txt | AC | 202 ms | 19912 KiB |
| 037.txt | AC | 115 ms | 20100 KiB |
| 038.txt | AC | 246 ms | 27832 KiB |
| 039.txt | AC | 299 ms | 28568 KiB |
| 040.txt | AC | 115 ms | 21996 KiB |
| 041.txt | AC | 290 ms | 33228 KiB |
| 042.txt | AC | 408 ms | 39176 KiB |
| 043.txt | AC | 122 ms | 22480 KiB |
| 044.txt | AC | 277 ms | 33668 KiB |
| 045.txt | AC | 408 ms | 40408 KiB |
| 046.txt | AC | 120 ms | 23188 KiB |
| 047.txt | AC | 278 ms | 34512 KiB |
| 048.txt | AC | 381 ms | 41440 KiB |
| 049.txt | AC | 102 ms | 22932 KiB |
| 050.txt | AC | 151 ms | 26936 KiB |
| 051.txt | AC | 375 ms | 41704 KiB |
| 052.txt | AC | 115 ms | 23080 KiB |
| 053.txt | AC | 114 ms | 23120 KiB |
| 054.txt | AC | 360 ms | 41752 KiB |
| 055.txt | AC | 101 ms | 23176 KiB |
| 056.txt | AC | 298 ms | 39580 KiB |
| 057.txt | AC | 340 ms | 41864 KiB |
| 058.txt | AC | 106 ms | 23008 KiB |
| 059.txt | AC | 224 ms | 33860 KiB |
| 060.txt | AC | 305 ms | 41808 KiB |
| example0.txt | AC | 13 ms | 12972 KiB |