Submission #4675666


Source Code Expand

Copy
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<LL,LL> pa;
typedef long double ld;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
bool u[500010];
int nedge,ap[500010],too[500010],top,n,m,D,S,d[500010],x,y,tp,stk[500010],hed[500010],nxt[500010];
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void dfs(int x){
	for (int i=hed[x];i;i=hed[x]){
		hed[x]=nxt[i];
		if (u[i]) continue;
		u[i]=u[i^1]=1;
		int y=too[i];
		dfs(y);
	}
	stk[++top]=x;
}
int main(){
	scanf("%d%d",&n,&m);
	if (n==1) return puts("No"),0;
	nedge=1;
	FOR(i,1,m){
		getint(x),getint(y);
		ae(x,y),ae(y,x);
		++d[x],++d[y];
	}
	FOR(i,1,n) if (d[i]&1) return puts("No"),0;
	FOR(i,1,n) if (d[i]>=6) return puts("Yes"),0;
	S=1;
	dfs(S);
	--top;
	assert((top==m));
//	FORD(i,top,1) printf("%d ",stk[i]);
	reverse(stk+1,stk+top+1);
	FOR(i,top+1,top+top) stk[i]=stk[i-top];
	memset(nxt,0,sizeof(nxt));
	FOR(i,1,n) ap[i]=top+top+1;
	nxt[top+top+1]=top*10+10;
	FORD(i,top+top,1){
		int t=ap[stk[i]];
		nxt[i]=min(nxt[i+1],t);
		if (i<=top && ap[stk[i]]<top+i-1){
			if (nxt[ap[stk[i]]+1]<=top+i-1){
				return puts("Yes"),0;
			}
		}
		ap[stk[i]]=i;
	}
	puts("No");
	return 0;
}

Submission Info

Submission Time
Task C - Three Circuits
User cwystc
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1594 Byte
Status
Exec Time 22 ms
Memory 13824 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 800 / 800 sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt
Case Name Status Exec Time Memory
sample_01.txt 2 ms 4352 KB
sample_02.txt 3 ms 10368 KB
sample_03.txt 2 ms 4352 KB
test_01.txt 6 ms 11264 KB
test_02.txt 4 ms 10624 KB
test_03.txt 3 ms 10368 KB
test_04.txt 19 ms 13184 KB
test_05.txt 8 ms 11392 KB
test_06.txt 14 ms 12800 KB
test_07.txt 4 ms 10368 KB
test_08.txt 3 ms 10368 KB
test_09.txt 22 ms 13824 KB
test_10.txt 19 ms 13312 KB
test_11.txt 10 ms 11904 KB
test_12.txt 10 ms 11904 KB
test_13.txt 10 ms 12032 KB
test_14.txt 10 ms 11904 KB
test_15.txt 12 ms 12160 KB
test_16.txt 13 ms 12416 KB
test_17.txt 9 ms 11648 KB
test_18.txt 10 ms 11648 KB
test_19.txt 13 ms 12288 KB
test_20.txt 15 ms 12288 KB
test_21.txt 11 ms 12160 KB
test_22.txt 8 ms 11520 KB
test_23.txt 3 ms 10368 KB
test_24.txt 3 ms 10368 KB
test_25.txt 4 ms 10368 KB
test_26.txt 3 ms 10368 KB
test_27.txt 12 ms 12032 KB
test_28.txt 13 ms 11904 KB
test_29.txt 10 ms 11776 KB
test_30.txt 10 ms 11776 KB
test_31.txt 16 ms 13056 KB
test_32.txt 12 ms 12288 KB
test_33.txt 11 ms 11776 KB
test_34.txt 15 ms 12672 KB
test_35.txt 13 ms 12416 KB
test_36.txt 13 ms 12160 KB
test_37.txt 12 ms 12160 KB
test_38.txt 13 ms 12032 KB
test_39.txt 2 ms 4352 KB
test_40.txt 13 ms 9344 KB
test_41.txt 8 ms 8960 KB
test_42.txt 7 ms 8960 KB
test_43.txt 10 ms 9088 KB
test_44.txt 11 ms 9216 KB
test_45.txt 9 ms 9088 KB
test_46.txt 10 ms 9088 KB
test_47.txt 12 ms 9216 KB
test_48.txt 9 ms 9088 KB
test_49.txt 11 ms 9216 KB
test_50.txt 12 ms 9216 KB
test_51.txt 11 ms 9216 KB
test_52.txt 10 ms 9216 KB
test_53.txt 5 ms 6784 KB
test_54.txt 6 ms 6784 KB
test_55.txt 7 ms 6912 KB
test_56.txt 6 ms 6784 KB
test_57.txt 7 ms 7040 KB
test_58.txt 7 ms 6784 KB
test_59.txt 9 ms 7040 KB