| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1335974 | cansu_mutlu | Social Engineering (EGOI22_socialengineering) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "socialengineering.h"
using namespace std;
void SocialEngineering(int n,int m, vector<pair<int,int>> edges)
{
vector<vector<pair<int,int>>> a(n+1);
int num = 0;
for(auto x:edges)
{
int u = x.first,v = x.second;
a[u].push_back({v,num});
a[v].push_back({u,num});
num++;
}
vector<int> vis(n+1,0),v(num,0);
int ok = 1;
if((a[1].size())%2) return;
int i =1;
while(1)
{
i = GetMove();
if(i==0) break;
queue<int> q;
q.push(i);vis[i]++;
while ((q.size()))
{
int s = q.front();
if(s==1) break;
q.pop();
for(auto x:a[s])
{
if(v[x.second]==0)
{
v[x.second] = 1;
vis[x.first]++;
//if(x.first!=1)
MakeMove(x.first);
q.push(x.first);
break;
}
}
}
if(q.empty())
{
return;
}
}
return;
}