Submission #914264

# Submission time Handle Problem Language Result Execution time Memory
914264 2024-01-21T13:30:12 Z 3as8 Joker (BOI20_joker) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

#define ll long long
#define endl "\n"
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);

#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)

using namespace std;

struct node {
    ll u, i;
};

bool dfs(vector<vector<node> >& graph, vector<bool>& visited, ll startIndex, ll p, ll l, ll r) {
    
    visited[startIndex] = true;

    ll ret = false;
    for(auto [el, i] : graph[startIndex]) {
        if(el == p || (l <= i && i <= r)) continue;
        if(visited[el]) return true;

        ret |= dfs(graph, visited, el, startIndex, l, r);
    }

    return ret;
}

void solve(ll _) {

    ll n, m, q; cin>>n>>m>>q;

    vector<vector<node> > graph(n);
    for(int i = 0; i < m; i++) {
        ll x, y; cin>>x>>y;
        x--; y--;

        graph[x].push_back({y, i});
        graph[y].push_back({x, i});
    }

    for(int i = 0; i < n; i++) {
        ll l, r; cin>>l>>r;
        l--; r--;

        vector<bool> visited(n);

        ll ans = false;
        for(int j = 0; j < n; j++) {
            if(visited[j]) continue;
            ans |= dfs(graph, visited, j, -1, l, r);
        }

        cout<<(ans ? "YES" : "NO")<<endl;
    }

}

int main() {
    //fastIO

    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);

    ll t = 0; solve(t);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -