Submission #753280

#TimeUsernameProblemLanguageResultExecution timeMemory
753280boyliguanhanTug of War (BOI15_tug)C++17
23 / 100
29 ms11596 KiB
#include<bits/stdc++.h> using namespace std; multiset<int> adj[200100]; queue<int> q; int main() { int n; cin >> n; n*=2; for(int i = 1; i <= n; i++) { int x, y, z; cin >> x >> x >> y; y+=n/2; adj[x].insert(y); adj[y].insert(x); } for(int i = 1; i <= n; i++) { if(!adj[i].size()) { cout << "NO\n"; return 0; } if(adj[i].size()<2) q.push(i); } while(q.size()) { int x = q.front(), i = *adj[x].begin(); q.pop(); adj[i].erase(x); if(!adj[i].size()) { cout << "NO\n"; return 0; } if(adj[i].size()<2) q.push(i); } cout << "YES\n"; }

Compilation message (stderr)

tug.cpp: In function 'int main()':
tug.cpp:10:19: warning: unused variable 'z' [-Wunused-variable]
   10 |         int x, y, z;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...