답안 #689301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689301 2023-01-28T06:15:52 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((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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 127 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 127 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Execution timed out 2080 ms 21920 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 127 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 127 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5020 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Runtime error 127 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -