Submission #721123

# Submission time Handle Problem Language Result Execution time Memory
721123 2023-04-10T10:28:05 Z saayan007 Jail (JOI22_jail) C++17
0 / 100
2 ms 3156 KB
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define fr first
#define sc second
#define eb emplace_back
#define nl "\n"

const int N = 120001;
int n, m;
vector<int> adj[N];
int s[N], t[N];
int from[N];
int use[N];

void dfs(int cur, int par) {
    from[cur] = par;
    for(auto u : adj[cur]) {
        if(u != par)
            dfs(u, cur);
    }
}

void mod(int a, int b, int v = 1) {
    dfs(a, 0);
    while(b != 0) {
        use[b] += v;
        b = from[b];
    }
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        use[i] = 0;
        adj[i].clear();
    }
    for(int i = 1; i < n; ++i) {
        int a, b; cin >> a >> b;
        adj[a].eb(b); adj[b].eb(a);
    }

    cin >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> s[i] >> t[i];
    }

    int o[m + 1];
    for(int i = 1; i <= m; ++i) o[i] = i;
    sort(o + 1, o + m + 1, [&](int l, int r){
        return make_pair(s[l], t[l]) < make_pair(s[r], t[r]);
    });

    for(int i = 1; i < m; ++i) {
        int j = o[i], k = o[i + 1];
        if(s[k] <= t[j]) {
            cout << "No" << nl;
            return;
        }
    }
    cout << "Yes" << nl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; ++i) {
        /* cout << "Case #" << i << nl; */
        solve();
        /* cout << nl; */
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -