| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1351421 | pineapple0006 | Social Engineering (EGOI22_socialengineering) | C++17 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "socialengineering.h"
using namespace std;
typedef long long ll;
vector<vector<ll>> adj;
vector<bool> visited;
ll findPathCountToCenter(ll v)
{
visited[v] = true;
ll res = 0;
for (ll i : adj[v])
{
if (i == 1)
{
res++;
}
if (visited[i])
{
continue;
}
res += findPathCountToCenter(i);
}
return res;
}
void SocialEngineering(int n, int m, vector<pair<int, int>> edges)
{
adj.resize(n + 1);
visited.resize(n + 1, false);
visited[1] = true;
for (pair<int, int> p : edges)
{
adj[p.first].push_back(p.second);
adj[p.second].push_back(p.first);
}
for (ll i : adj[1])
{
if (visited[i])
{
continue;
}
ll path_count = findPathCountToCenter(i);
if (path_count % 2 == 1)
{
return;
};
}
GetMove();
return;
}
#ifdef LOCAL
#include "grader.cpp"
#endif