답안 #882225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882225 2023-12-02T20:12:01 Z RaresFelix Jail (JOI22_jail) C++17
5 / 100
53 ms 11720 KB
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int te;
    cin >> te;
    while(te--) {
        int n;
        cin >> n;
        for(int i = 1; i < n; ++i) {
            int a, b;
            cin >> a >> b;
        }
        int m;
        cin >> m;

        vi S(m), T(m);

        vector<vi> Ev(n);
        vector<pair<int, int> > P;
        
        for(int i = 0; i < m; ++i) {
            int s, t;
            cin >> s >> t;
            --s; --t;
            P.push_back({min(s, t), max(s, t)});
            S[i] = s;
            T[i] = t;
            Ev[min(s, t)].push_back(i);
            Ev[max(s, t)].push_back(-i - 1);
        }
        sort(P.begin(), P.end());
        int ma = -1;
        int nr1 = 0, nr2 = 0, ok = 1;
        for(auto [l, r] : P) {
            if(r < ma) ok = 0;
            ma = max(r, ma);
        }
        for(int i = 0; i < n; ++i) {
            for(auto it : Ev[i]) {
                if(it >= 0) {
                    if(S[it] < T[it]) ++nr1;
                    else ++nr2;
                }
            }
            if(nr1 && nr2) ok = 0;
            for(auto it : Ev[i]) {
                if(it < 0) {
                    int i = -it - 1;
                    if(S[i] < T[i]) --nr1;
                    else --nr2;
                }
            }
        }
        if(ok) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 11 ms 1080 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 16 ms 1852 KB Output is correct
10 Correct 15 ms 4700 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 20 ms 1372 KB Output is correct
13 Correct 26 ms 9152 KB Output is correct
14 Correct 27 ms 9068 KB Output is correct
15 Correct 36 ms 8400 KB Output is correct
16 Correct 53 ms 11720 KB Output is correct
17 Correct 37 ms 10092 KB Output is correct
18 Correct 40 ms 11668 KB Output is correct
19 Correct 28 ms 9928 KB Output is correct
20 Correct 29 ms 9932 KB Output is correct
21 Correct 29 ms 9936 KB Output is correct
22 Correct 30 ms 10060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 11 ms 1080 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 16 ms 1852 KB Output is correct
10 Correct 15 ms 4700 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 20 ms 1372 KB Output is correct
13 Correct 26 ms 9152 KB Output is correct
14 Correct 27 ms 9068 KB Output is correct
15 Correct 36 ms 8400 KB Output is correct
16 Correct 53 ms 11720 KB Output is correct
17 Correct 37 ms 10092 KB Output is correct
18 Correct 40 ms 11668 KB Output is correct
19 Correct 28 ms 9928 KB Output is correct
20 Correct 29 ms 9932 KB Output is correct
21 Correct 29 ms 9936 KB Output is correct
22 Correct 30 ms 10060 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Incorrect 1 ms 348 KB Output isn't correct
27 Halted 0 ms 0 KB -