Submission #3677114
Source Code Expand
#include<stdio.h> #include<algorithm> #include<set> using namespace std; int mat[500][500]; int UF[500]; int FIND(int a){ if(UF[a]<0)return a; return UF[a]=FIND(UF[a]); } void UNION(int a,int b){ a=FIND(a); b=FIND(b); if(a==b)return; UF[a]+=UF[b]; UF[b]=a; } int main(){ int a,b; scanf("%d%d",&a,&b); if(a>=500){ for(int i=0;i<b;i++)printf("no\n"); return 0; } for(int i=0;i<a;i++){ for(int j=0;j<a;j++)mat[i][j]=1; } int now=a*(a-1)/2; set<pair<int,int> >edge; for(int i=0;i<a;i++) for(int j=i+1;j<a;j++)edge.insert(make_pair(i,j)); for(int i=0;i<b;i++){ int c,d;scanf("%d%d",&c,&d); c--;d--; if(mat[c][d]){ mat[c][d]=mat[d][c]=0; edge.erase(make_pair(min(c,d),max(c,d))); now--; }else{ mat[c][d]=mat[d][c]=1; now++; edge.insert(make_pair(min(c,d),max(c,d))); } if(now<a){ for(int j=0;j<a;j++)UF[j]=-1; set<pair<int,int> >::iterator it=edge.begin(); bool ok=true; while(it != edge.end()){ int S=(*it).first; int T=(*it).second; if(FIND(S)==FIND(T))ok=false; else UNION(S,T); ++it; } if(ok)printf("yes\n"); else printf("no\n"); }else printf("no\n"); } }
Submission Info
Submission Time | |
---|---|
Task | C - 森ですか? |
User | luogu_bot3 |
Language | C++ (GCC 5.4.1) |
Score | 100 |
Code Size | 1210 Byte |
Status | AC |
Exec Time | 178 ms |
Memory | 7168 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&a,&b); ^ ./Main.cpp:33:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int c,d;scanf("%d%d",&c,&d); ^
Judge Result
Set Name | Easy | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 50 / 50 | 50 / 50 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Easy | easy_01_00.txt, easy_01_01.txt, easy_01_02.txt, easy_01_03.txt, easy_01_04.txt, easy_02_00.txt, easy_02_01.txt, easy_02_02.txt, easy_02_03.txt, easy_02_04.txt, easy_03_00.txt, easy_03_01.txt, easy_03_02.txt, easy_03_03.txt, easy_03_04.txt, easy_04_00.txt, easy_04_01.txt, easy_04_02.txt, easy_04_03.txt, easy_04_04.txt, easy_05_00.txt, easy_05_01.txt, easy_05_02.txt, easy_05_03.txt, easy_05_04.txt, easy_06_00.txt, easy_06_01.txt, easy_06_02.txt, easy_06_03.txt, easy_06_04.txt, easy_07_00.txt, easy_07_01.txt, easy_07_02.txt, easy_07_03.txt, easy_07_04.txt, easy_08_00.txt, easy_08_01.txt |
All | easy_01_00.txt, easy_01_01.txt, easy_01_02.txt, easy_01_03.txt, easy_01_04.txt, easy_02_00.txt, easy_02_01.txt, easy_02_02.txt, easy_02_03.txt, easy_02_04.txt, easy_03_00.txt, easy_03_01.txt, easy_03_02.txt, easy_03_03.txt, easy_03_04.txt, easy_04_00.txt, easy_04_01.txt, easy_04_02.txt, easy_04_03.txt, easy_04_04.txt, easy_05_00.txt, easy_05_01.txt, easy_05_02.txt, easy_05_03.txt, easy_05_04.txt, easy_06_00.txt, easy_06_01.txt, easy_06_02.txt, easy_06_03.txt, easy_06_04.txt, easy_07_00.txt, easy_07_01.txt, easy_07_02.txt, easy_07_03.txt, easy_07_04.txt, easy_08_00.txt, easy_08_01.txt, hard_01_00.txt, hard_01_01.txt, hard_01_02.txt, hard_01_03.txt, hard_01_04.txt, hard_02_00.txt, hard_02_01.txt, hard_02_02.txt, hard_02_03.txt, hard_02_04.txt, hard_03_00.txt, hard_03_01.txt, hard_03_02.txt, hard_03_03.txt, hard_03_04.txt, hard_04_00.txt, hard_04_01.txt, hard_04_02.txt, hard_04_03.txt, hard_04_04.txt, hard_05_00.txt, hard_05_01.txt, hard_05_02.txt, hard_05_03.txt, hard_05_04.txt, hard_06_00.txt, hard_06_01.txt, hard_06_02.txt, hard_06_03.txt, hard_06_04.txt, hard_07_00.txt, hard_07_01.txt, hard_07_02.txt, hard_07_03.txt, hard_07_04.txt, hard_08_00.txt, hard_08_01.txt, hard_09_00.txt, hard_09_01.txt, hard_09_02.txt, hard_09_03.txt, hard_09_04.txt, sample1.txt, sample2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
easy_01_00.txt | AC | 1 ms | 256 KB |
easy_01_01.txt | AC | 1 ms | 256 KB |
easy_01_02.txt | AC | 1 ms | 256 KB |
easy_01_03.txt | AC | 1 ms | 256 KB |
easy_01_04.txt | AC | 1 ms | 256 KB |
easy_02_00.txt | AC | 2 ms | 512 KB |
easy_02_01.txt | AC | 1 ms | 384 KB |
easy_02_02.txt | AC | 1 ms | 256 KB |
easy_02_03.txt | AC | 2 ms | 512 KB |
easy_02_04.txt | AC | 2 ms | 512 KB |
easy_03_00.txt | AC | 1 ms | 256 KB |
easy_03_01.txt | AC | 1 ms | 256 KB |
easy_03_02.txt | AC | 1 ms | 256 KB |
easy_03_03.txt | AC | 1 ms | 256 KB |
easy_03_04.txt | AC | 1 ms | 256 KB |
easy_04_00.txt | AC | 1 ms | 512 KB |
easy_04_01.txt | AC | 1 ms | 384 KB |
easy_04_02.txt | AC | 2 ms | 512 KB |
easy_04_03.txt | AC | 1 ms | 256 KB |
easy_04_04.txt | AC | 1 ms | 512 KB |
easy_05_00.txt | AC | 1 ms | 256 KB |
easy_05_01.txt | AC | 1 ms | 256 KB |
easy_05_02.txt | AC | 1 ms | 256 KB |
easy_05_03.txt | AC | 1 ms | 256 KB |
easy_05_04.txt | AC | 1 ms | 256 KB |
easy_06_00.txt | AC | 1 ms | 384 KB |
easy_06_01.txt | AC | 1 ms | 384 KB |
easy_06_02.txt | AC | 1 ms | 512 KB |
easy_06_03.txt | AC | 2 ms | 512 KB |
easy_06_04.txt | AC | 1 ms | 384 KB |
easy_07_00.txt | AC | 1 ms | 256 KB |
easy_07_01.txt | AC | 1 ms | 256 KB |
easy_07_02.txt | AC | 1 ms | 256 KB |
easy_07_03.txt | AC | 1 ms | 256 KB |
easy_07_04.txt | AC | 1 ms | 256 KB |
easy_08_00.txt | AC | 1 ms | 256 KB |
easy_08_01.txt | AC | 1 ms | 256 KB |
hard_01_00.txt | AC | 80 ms | 5632 KB |
hard_01_01.txt | AC | 59 ms | 3456 KB |
hard_01_02.txt | AC | 66 ms | 4224 KB |
hard_01_03.txt | AC | 46 ms | 1920 KB |
hard_01_04.txt | AC | 46 ms | 1920 KB |
hard_02_00.txt | AC | 2 ms | 384 KB |
hard_02_01.txt | AC | 3 ms | 384 KB |
hard_02_02.txt | AC | 3 ms | 512 KB |
hard_02_03.txt | AC | 3 ms | 512 KB |
hard_02_04.txt | AC | 3 ms | 512 KB |
hard_03_00.txt | AC | 65 ms | 4352 KB |
hard_03_01.txt | AC | 48 ms | 2176 KB |
hard_03_02.txt | AC | 74 ms | 5376 KB |
hard_03_03.txt | AC | 64 ms | 4096 KB |
hard_03_04.txt | AC | 77 ms | 5632 KB |
hard_04_00.txt | AC | 47 ms | 3712 KB |
hard_04_01.txt | AC | 3 ms | 512 KB |
hard_04_02.txt | AC | 14 ms | 1408 KB |
hard_04_03.txt | AC | 2 ms | 384 KB |
hard_04_04.txt | AC | 17 ms | 1920 KB |
hard_05_00.txt | AC | 87 ms | 6016 KB |
hard_05_01.txt | AC | 170 ms | 2688 KB |
hard_05_02.txt | AC | 143 ms | 4864 KB |
hard_05_03.txt | AC | 108 ms | 5632 KB |
hard_05_04.txt | AC | 86 ms | 6016 KB |
hard_06_00.txt | AC | 48 ms | 6144 KB |
hard_06_01.txt | AC | 2 ms | 384 KB |
hard_06_02.txt | AC | 78 ms | 7168 KB |
hard_06_03.txt | AC | 30 ms | 1920 KB |
hard_06_04.txt | AC | 85 ms | 1280 KB |
hard_07_00.txt | AC | 85 ms | 6016 KB |
hard_07_01.txt | AC | 122 ms | 5376 KB |
hard_07_02.txt | AC | 178 ms | 3712 KB |
hard_07_03.txt | AC | 125 ms | 5376 KB |
hard_07_04.txt | AC | 137 ms | 5120 KB |
hard_08_00.txt | AC | 78 ms | 6144 KB |
hard_08_01.txt | AC | 79 ms | 6144 KB |
hard_09_00.txt | AC | 56 ms | 4096 KB |
hard_09_01.txt | AC | 46 ms | 3072 KB |
hard_09_02.txt | AC | 45 ms | 2816 KB |
hard_09_03.txt | AC | 51 ms | 3584 KB |
hard_09_04.txt | AC | 44 ms | 2816 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |