답안 #753280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753280 2023-06-05T01:56:27 Z boyliguanhan Tug of War (BOI15_tug) C++17
23 / 100
29 ms 11596 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;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 11468 KB Output is correct
2 Correct 25 ms 11512 KB Output is correct
3 Correct 21 ms 11520 KB Output is correct
4 Correct 21 ms 11568 KB Output is correct
5 Correct 22 ms 11484 KB Output is correct
6 Correct 21 ms 11476 KB Output is correct
7 Correct 22 ms 11512 KB Output is correct
8 Correct 29 ms 11520 KB Output is correct
9 Correct 24 ms 11596 KB Output is correct
10 Correct 21 ms 11492 KB Output is correct
11 Correct 23 ms 11564 KB Output is correct
12 Correct 22 ms 11528 KB Output is correct
13 Correct 20 ms 11476 KB Output is correct
14 Correct 20 ms 11560 KB Output is correct
15 Correct 23 ms 11512 KB Output is correct
16 Correct 20 ms 11544 KB Output is correct
17 Correct 24 ms 11476 KB Output is correct
18 Correct 29 ms 11524 KB Output is correct
19 Correct 22 ms 11476 KB Output is correct
20 Correct 21 ms 11532 KB Output is correct
21 Correct 21 ms 11528 KB Output is correct
22 Correct 23 ms 11576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -