結果

問題 No.3321 岩井星人グラフ-1
コンテスト
ユーザー Neculapia
提出日時 2025-11-25 13:21:55
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 633 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,610 ms
コンパイル使用メモリ 281,604 KB
実行使用メモリ 21,116 KB
最終ジャッジ日時 2025-11-25 13:22:08
合計ジャッジ時間 12,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48 WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<int> deg(N);
vector<vector<int>> g(N);
for(int i=0;i<M;i++){
int a,b;cin>>a>>b;--a;--b;
g[a].push_back(b);
g[b].push_back(a);
deg[a]++;deg[b]++;
}
int c0=0,c1=0,c2=0,c3=0;
for(int d:deg){
if(d==0)c0++;
else if(d==1)c1++;
else if(d==2)c2++;
else if(d==3)c3++;
else {cout<<"No\n";return 0;}
}
if(M+1!=N){cout<<"No\n";return 0;}

bool ok=false;
if(c0==0&&c1==3&&c3==1)ok=true;
if(c0==1&&c1==3&&c3==3)ok=true;
if(c0==0&&c1==4&&c3==2)ok=true;
if(c0==0&&c1==5&&c3==3)ok=true;

cout<<(ok?"Yes\n":"No\n");

}
0