結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
yixuan peng
|
| 提出日時 | 2025-04-19 13:44:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,198 bytes |
| コンパイル時間 | 2,208 ms |
| コンパイル使用メモリ | 198,088 KB |
| 実行使用メモリ | 376,096 KB |
| 最終ジャッジ日時 | 2025-04-19 13:44:58 |
| 合計ジャッジ時間 | 5,250 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 2 MLE * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:58:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
58 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:60:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
60 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int N=2e4+5,M=5e4+5;
int n,m,k,cnt,dis[N],c[N],d[N],head[N];
bool ck[N][N],vis[N];
struct edge{
int to,nxt;
}e[M<<1];
void add(int u,int v){
e[++cnt]=(edge){v,head[u]};
head[u]=cnt;
}
void bfs(){
queue<int> q;
for(int i=head[1];i;i=e[i].nxt){
int v=e[i].to;
q.push(v);
}
while(!q.empty()){
int p=q.front();q.pop();
for(int i=head[p];i;i=e[i].nxt){
int v=e[i].to;
vis[v]=true;
c[v]++;
d[v]=p;
}
}
}
bool check(int x,int y){
if(c[x]==1){
if(c[y]==1){
if(d[y]!=x&&d[y]!=d[x]&&d[x]!=y) return true;
return false;
}
else{
if(d[x]!=y) return true;
return false;
}
}
else{
if(c[y]==1){
if(d[y]!=x) return true;
return false;
}
else return true;
}
}
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;
}
bfs();
for(int i=2;i<=n;i++){
if(!vis[i]) continue;
for(int j=head[i];j;j=e[j].nxt){
int v=e[j].to;
if(!vis[v]) continue;
if(check(i,v)){
printf("YES");
return 0;
}
}
}
printf("NO");
return 0;
}
yixuan peng