# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094614 | Roumak77 | Curtains (NOI23_curtains) | C++17 | 3 ms | 2140 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
ll recur(ll curr, vector<bool> &vis, vector<vector<ll>> &adj){
vis[curr] = true;
ll total = 1;
for(ll node : adj[curr]){
if(!vis[node]){
total += recur(node, vis, adj);
}
}
return total;
}
void solve(){
ll n, m;
cin >> n >> m;
vector<vector<ll>> adj(n, vector<ll>());
for(ll i = 0; i < m; i++){
ll a, b;
cin >> a >> b;
a--; b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
vector<bool> main_vis(n, false);
vector<bool> temp(n, false);
for(ll i = 0; i < n; i++){
temp = main_vis;
ll curr = 0;
for(ll j = 0; j < n; j++){
if(!main_vis[j]){
curr = j;
break;
}
}
if(recur(curr, temp, adj) == n - i){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
ll k;
cin >> k;
k--;
main_vis[k] = true;
}
}
bool single = true;
int main(){
freopen("closing.in", "r", stdin);
freopen("closing.out", "w", stdout);
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
ll t = 1;
if(!single) cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |