結果
| 問題 | No.2664 Prime Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-08 23:07:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,991 bytes |
| コンパイル時間 | 1,082 ms |
| コンパイル使用メモリ | 114,104 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-29 20:36:40 |
| 合計ジャッジ時間 | 2,035 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 |
ソースコード
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<queue>
#include<complex>
#include <cassert>
using namespace std;
//conversion
//------------------------------------------
inline long long toint(string s) {long long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef long long ll;
typedef long long LL;
typedef vector<int > vi;
typedef vector<long long > VLL;
typedef vector<long long > vll;
typedef vector<string > ves;
typedef vector<char > vech;
typedef pair<long long , long long> pll;
typedef pair<long long , long long> PLL;
typedef map<ll , ll >mll;
typedef map<int , int >mii;
typedef map<char , int >mci;
typedef map<char , ll >mcl;
typedef vector<pair<ll , ll> > vpll;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define VECMAX(x) *max_element(ALL(x))
#define VECMIN(x) *min_element(ALL(x))
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//#define MULTIPLE(i,n,k) for(int i = (k) ; i<(n) ; i+=k+1)//倍数ループ
//constant
//------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define SIZEOF(x) sizeof(x)/sizeof(x[0])
const long long INF = 4e18;
const long long NINF = 1 - INF;
#define ENDL cout << endl;
#define CIN(a) REP(i,a.size())cin >> a[i];
//二次元座標の点を表す構造体。xとyをメンバに持つ
struct POINT{
double x;
double y;
};
//最小公倍数、最大公約数
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
/*
nCr , 値が大きいとオーバーフローする
n<=kなら1 (0C1や1C5= 1)
*/
ll nCr(ll n, ll r){
if ( r * 2 > n ) r = n - r;
ll dividend = 1;
ll divisor = 1;
for ( unsigned int i = 1; i <= r; ++i ) {
dividend *= (n-i+1);
divisor *= i;
}
return dividend / divisor;
}
int main(){
ll n , m;cin >> n >> m;
vector<vll>G(n+1);
REP(i,m){
ll a , b;cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
bool ok = true;
vll memo(n+1,-1);
REP(i,n+1){
if(memo[i] != -1)continue;
ll r = i;
stack<ll> s;
s.push(r);
memo[r] = 0;
while(!s.empty()){
ll now = s.top();
s.pop();
for(ll nx : G[now]){
if(memo[nx] != -1){
if(memo[nx] == memo[now]){
ok = false;
break;
}
continue;
}
memo[nx] = memo[now]^1;
s.push(nx);
}
}
}
if(ok)cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}