結果

問題 No.2664 Prime Sum
ユーザー KeebyKeeby
提出日時 2024-05-25 20:10:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,716 bytes
コンパイル時間 3,218 ms
コンパイル使用メモリ 254,864 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-25 20:10:13
合計ジャッジ時間 4,811 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
#define rep(i,n) for(long long i=0;i<n;i++)
#define rep1(i,n) for(long long i=1;i<=n;i++)
#define Rep(i,a,b) for(long long i=a;i<=b;i++)
#define all(a) (a).begin(), (a).end()
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vvec;
typedef vector<long long> vecll;
typedef vector<vector<long long>> vvecll;

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

const ll mod=998244353;
//const ll mod=1e9+7;
const ll INF=5e18;
const int INT_INF=1e9+100;
const double pi=3.14159265358979;

//xのn乗をpで割ったあまりを求める
ll modpow(ll x,ll n,ll p=mod){
  if(n==0) return 1;
  if(n%2==1) return (x*modpow(x,n-1,p))%p;
  else{
    ll t=modpow(x,n/2,p);
    assert(t>0);
    return (t*t)%p;
  }
}

//xの逆元(p:素数)
ll inv(ll x,ll p=mod){
  return modpow(x,p-2,p);
}

template <typename T>
int index(vector<T> &a, T x){
	return lower_bound(all(a),x)-a.begin();
}


int main(){
	int n,m;
  cin >> n >> m;
  vvec g(n+1,vec());
  rep(i,m){
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vec color(n+1,-1);
  bool ans=true;
  rep1(i,n){
    if(color[i]!=-1) continue;
    color[i]=0;
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int x=q.front();
      q.pop();
      for(int y:g[x]){
        if(color[y]==-1){
          color[y]=color[x]^1;
          q.push(y);
        }else{
          ans&=(color[x]!=color[y]);
        }
      }
    }
  }
  cout << (ans?"Yes":"No") << endl;
	return 0;
}
0