Submission #1094614

#TimeUsernameProblemLanguageResultExecution timeMemory
1094614Roumak77Curtains (NOI23_curtains)C++17
0 / 100
3 ms2140 KiB
#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)

curtains.cpp: In function 'int main()':
curtains.cpp:80:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |     freopen("closing.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:81:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |     freopen("closing.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...