Submission #753279

# Submission time Handle Problem Language Result Execution time Memory
753279 2023-06-05T01:56:14 Z vjudge1 Tug of War (BOI15_tug) C++17
23 / 100
32 ms 11804 KB
#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

tug.cpp: In function 'int main()':
tug.cpp:10:19: warning: unused variable 'z' [-Wunused-variable]
   10 |         int x, y, z;
      |                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11784 KB Output is correct
2 Correct 27 ms 11788 KB Output is correct
3 Correct 22 ms 11740 KB Output is correct
4 Correct 27 ms 11764 KB Output is correct
5 Correct 30 ms 11764 KB Output is correct
6 Correct 24 ms 11772 KB Output is correct
7 Correct 22 ms 11716 KB Output is correct
8 Correct 23 ms 11688 KB Output is correct
9 Correct 21 ms 11700 KB Output is correct
10 Correct 27 ms 11724 KB Output is correct
11 Correct 22 ms 11728 KB Output is correct
12 Correct 24 ms 11732 KB Output is correct
13 Correct 27 ms 11716 KB Output is correct
14 Correct 23 ms 11776 KB Output is correct
15 Correct 32 ms 11796 KB Output is correct
16 Correct 22 ms 11796 KB Output is correct
17 Correct 23 ms 11772 KB Output is correct
18 Correct 23 ms 11732 KB Output is correct
19 Correct 23 ms 11804 KB Output is correct
20 Correct 22 ms 11760 KB Output is correct
21 Correct 24 ms 11716 KB Output is correct
22 Correct 24 ms 11732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9648 KB Output isn't correct
2 Halted 0 ms 0 KB -