#include <bits/stdc++.h>
using namespace std;
ifstream in("lol.in");
ofstream out("lol.out");
int n;
int m;
vector<int> g[25];
vector<int> gmask[(1 << 20) + 5];
int t[(1 << 20) + 5];
bool pot[(1 << 20) + 5];
void dfs(int mask)
{
pot[mask] = true;
for (auto vecin : gmask[mask])
if (!pot[vecin])
t[vecin] = mask,dfs(vecin);
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
int x,y;
cin >> x >> y;
x--;
y--;
g[x].push_back(y);
g[y].push_back(x);
}
if (m != n - 1)
{
cout << "NO";
return 0;
}
for (int mask = 1; mask < (1 << n); mask++)
{
for (int bit = 0; bit < n; bit++)
{
if (mask & (1 << bit))
{
bool huh[25];
for (int i = 0; i < n; i++)
{
if (i == bit or !(mask & (1 << i)))
huh[i] = true;
else
huh[i] = false;
}
int new_mask = 0;
for (int i = 0; i < n; i++)
{
bool iau = false;
for (auto vecin : g[i])
if (huh[vecin] == false)
iau = true;
if (iau)
new_mask += (1 << i);
}
gmask[new_mask].push_back(mask);
}
}
}
dfs(0);
if (pot[(1 << n) - 1])
{
cout << "YES\n\n";
/*int x = (1 << n) - 1;
while (x != 0)
{
cout << x << endl;
x = t[x];
}*/
}
else
cout << "NO";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
27736 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
27740 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
27736 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |