답안 #726661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
726661 2023-04-19T08:33:40 Z Johann Joker (BOI20_joker) C++14
14 / 100
2000 ms 11676 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

int N, M, Q;
vvpii adj;
vpii E;

bool possible_bfs(int l, int r)
{
    vi color(N, -1);
    queue<int> q;
    for (int v = 0; v < N; ++v)
    {
        if (color[v] != -1)
            continue;
        q.push(v), color[v] = 0;
        while (!q.empty())
        {
            int u = q.front();
            q.pop();
            for (pii e : adj[u])
            {
                if (e.second < l || e.second > r)
                {
                    if (color[e.first] == color[u])
                        return true;
                    if (color[e.first] == -1)
                    {
                        q.push(e.first);
                        color[e.first] = !color[u];
                    }
                }
            }
        }
    }
    return false;
}

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

    cin >> N >> M >> Q;
    adj.resize(N);
    E.resize(M);
    for (int i = 0, a, b; i < M; ++i)
    {
        cin >> a >> b;
        --a, --b;
        adj[a].push_back({b, i}), adj[b].push_back({a, i});
        E[i] = {min(a, b), max(a, b)};
    }

    for (int i = 0, l, r; i < Q; ++i)
    {
        cin >> l >> r;
        --l, --r; // [l, r] inclusive is blocked
        if (possible_bfs(l, r))
            cout << "YES\n";
        else
            cout << "NO\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 72 ms 440 KB Output is correct
30 Correct 60 ms 468 KB Output is correct
31 Correct 42 ms 488 KB Output is correct
32 Correct 20 ms 340 KB Output is correct
33 Correct 8 ms 468 KB Output is correct
34 Correct 41 ms 468 KB Output is correct
35 Correct 69 ms 464 KB Output is correct
36 Correct 19 ms 464 KB Output is correct
37 Correct 83 ms 468 KB Output is correct
38 Correct 82 ms 488 KB Output is correct
39 Correct 59 ms 496 KB Output is correct
40 Correct 24 ms 468 KB Output is correct
41 Correct 25 ms 460 KB Output is correct
42 Correct 26 ms 468 KB Output is correct
43 Correct 4 ms 340 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 12 ms 468 KB Output is correct
47 Correct 28 ms 460 KB Output is correct
48 Correct 31 ms 340 KB Output is correct
49 Correct 48 ms 468 KB Output is correct
50 Correct 54 ms 500 KB Output is correct
51 Correct 26 ms 340 KB Output is correct
52 Correct 32 ms 432 KB Output is correct
53 Correct 42 ms 488 KB Output is correct
54 Correct 61 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Execution timed out 2055 ms 9284 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Execution timed out 2055 ms 9284 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 72 ms 440 KB Output is correct
30 Correct 60 ms 468 KB Output is correct
31 Correct 42 ms 488 KB Output is correct
32 Correct 20 ms 340 KB Output is correct
33 Correct 8 ms 468 KB Output is correct
34 Correct 41 ms 468 KB Output is correct
35 Correct 69 ms 464 KB Output is correct
36 Correct 19 ms 464 KB Output is correct
37 Correct 83 ms 468 KB Output is correct
38 Correct 82 ms 488 KB Output is correct
39 Correct 59 ms 496 KB Output is correct
40 Correct 24 ms 468 KB Output is correct
41 Correct 25 ms 460 KB Output is correct
42 Correct 26 ms 468 KB Output is correct
43 Correct 4 ms 340 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 12 ms 468 KB Output is correct
47 Correct 28 ms 460 KB Output is correct
48 Correct 31 ms 340 KB Output is correct
49 Correct 48 ms 468 KB Output is correct
50 Correct 54 ms 500 KB Output is correct
51 Correct 26 ms 340 KB Output is correct
52 Correct 32 ms 432 KB Output is correct
53 Correct 42 ms 488 KB Output is correct
54 Correct 61 ms 464 KB Output is correct
55 Execution timed out 2017 ms 11676 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 72 ms 440 KB Output is correct
30 Correct 60 ms 468 KB Output is correct
31 Correct 42 ms 488 KB Output is correct
32 Correct 20 ms 340 KB Output is correct
33 Correct 8 ms 468 KB Output is correct
34 Correct 41 ms 468 KB Output is correct
35 Correct 69 ms 464 KB Output is correct
36 Correct 19 ms 464 KB Output is correct
37 Correct 83 ms 468 KB Output is correct
38 Correct 82 ms 488 KB Output is correct
39 Correct 59 ms 496 KB Output is correct
40 Correct 24 ms 468 KB Output is correct
41 Correct 25 ms 460 KB Output is correct
42 Correct 26 ms 468 KB Output is correct
43 Correct 4 ms 340 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 12 ms 468 KB Output is correct
47 Correct 28 ms 460 KB Output is correct
48 Correct 31 ms 340 KB Output is correct
49 Correct 48 ms 468 KB Output is correct
50 Correct 54 ms 500 KB Output is correct
51 Correct 26 ms 340 KB Output is correct
52 Correct 32 ms 432 KB Output is correct
53 Correct 42 ms 488 KB Output is correct
54 Correct 61 ms 464 KB Output is correct
55 Execution timed out 2055 ms 9284 KB Time limit exceeded
56 Halted 0 ms 0 KB -