Submission #689303

# Submission time Handle Problem Language Result Execution time Memory
689303 2023-01-28T06:19:51 Z saayan007 Joker (BOI20_joker) C++17
0 / 100
2000 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;

#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first 
#define sc second
#define mp make_pair
#define pb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll mxn = 2e5L + 1;
ll n, m, q;
vpl adj[mxn];
bool vis[mxn] = {};
ll dep[mxn] = {};
ll from[mxn] = {};

bool dfs(ll cur, ll src, ll l, ll r) {
    // cout << cur << ' ';
    if(vis[cur]) {
        if(src != -1 && (dep[src] + 1 - dep[cur]) % 2 == 1) {
            return 1;
        }
    }

    vis[cur] = 1;
    dep[cur] = (src == -1 ? 0 : dep[src] + 1);
    for(auto [ch, i] : adj[cur]) {
        if(ch != src && !(l <= i && i <= r)) {
            if(dfs(ch, cur, l, r)) {
                return 1;
            }
        }
    }
    return 0;
}

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

    cin >> n >> m >> q;
    fur(i, 1, m) {
        ll u, v;
        cin >> u >> v;
        adj[u].pb(v, i);
        adj[v].pb(u, i);
    }

    while(q--) {
        ll l, r;
        cin >> l >> r;

        fur(i, 1, n) {
            vis[i] = 0;
        }

        bool yes = 0;
        fur(i, 1, n) {
            if(!vis[i]) {
                if(dfs(i, -1, l, r)) {
                    yes = 1;
                    // cout << nl;
                }
            }
        }

        cout << (yes ? "YES" : "NO") << nl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Execution timed out 2067 ms 19360 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5028 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -