# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
753280 | boyliguanhan | Tug of War (BOI15_tug) | C++17 | 29 ms | 11596 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.
#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)
# | 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... |