Submission #882224

# Submission time Handle Problem Language Result Execution time Memory
882224 2023-12-02T20:05:45 Z RaresFelix Jail (JOI22_jail) C++17
0 / 100
5 ms 600 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);
        
        for(int i = 0; i < m; ++i) {
            int s, t;
            cin >> s >> t;
            --s; --t;
            S[i] = s;
            T[i] = t;
            Ev[min(s, t)].push_back(i);
            Ev[max(s, t)].push_back(-i - 1);
        }
        int nr1 = 0, nr2 = 0, ok = 1;
        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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 5 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
5 Incorrect 3 ms 460 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 5 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -