結果

問題 No.408 五輪ピック
ユーザー yixuan peng
提出日時 2025-04-19 13:34:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 875 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 192,184 KB
実行使用メモリ 364,436 KB
最終ジャッジ日時 2025-04-19 13:35:10
合計ジャッジ時間 16,579 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 TLE * 2 MLE * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:43:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |                 scanf("%d%d",&x,&y);
      |                 ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

const int N=2e4+5,M=5e4+5;

int n,m,k,cnt,head[N];
bool ck[N][N];

struct edge{
	int to,nxt;
}e[M<<1];

void add(int u,int v){
	e[++cnt]=(edge){v,head[u]};
	head[u]=cnt;
}

bool work(int x){
	for(int i=head[x];i;i=e[i].nxt){
		int a=e[i].to;
		for(int j=head[x];j;j=e[j].nxt){
			int b=e[j].to;
			if(b==a) break;
			for(int k=head[a];k;k=e[k].nxt){
				int c=e[k].to;
				if(c==b||c==x) continue;
				for(int l=head[b];l;l=e[l].nxt){
					int d=e[l].to;
					if(d==a||d==c||d==x) continue;
					if(ck[c][d]) return true;
				}
			}
		}
	}
	return false;
}

int main(){
//	freopen("circle.in","r",stdin);
//	freopen("circle.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
		ck[x][y]=ck[y][x]=true;
	}
	if(work(1)) printf("YES\n");
	else printf("NO\n");
	return 0;
}
0