답안 #1050395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050395 2024-08-09T09:04:05 Z duckindog Joker (BOI20_joker) C++17
14 / 100
195 ms 860 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 10;
int n, m, q;
vector<pair<int, int>> ad[N];
int co[N];

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n >> m >> q;
  for (int i = 1; i <= m; ++i) { 
    int u, v; cin >> u >> v;
    ad[u].push_back({v, i});
    ad[v].push_back({u, i});
  }

  auto color = [&](int st, int l, int r) { 
    bool ret = false;
    co[st] = 1;
    queue<int> q({st});
    while (q.size()) { 
      auto u = q.front(); q.pop();
      for (const auto& [v, id] : ad[u]) { 
        if (l <= id && id <= r) continue;
        if (co[v] == co[u]) ret = true;
        if (co[v]) continue;
        co[v] = co[u] ^ 3;
        q.push(v);
      }
    }
    return ret;
  };

  while (q--) { 
    int l, r; cin >> l >> r;
    memset(co, 0, sizeof co);
    bool answer = false;
    for (int i = 1; i <= n; ++i) if (!co[i]) answer |= color(i, l, r);
    cout << (answer ? "YES" : "NO") << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 504 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 504 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 158 ms 556 KB Output is correct
30 Correct 195 ms 600 KB Output is correct
31 Correct 129 ms 604 KB Output is correct
32 Correct 71 ms 604 KB Output is correct
33 Correct 45 ms 616 KB Output is correct
34 Correct 163 ms 860 KB Output is correct
35 Correct 175 ms 604 KB Output is correct
36 Correct 35 ms 604 KB Output is correct
37 Correct 99 ms 604 KB Output is correct
38 Correct 55 ms 600 KB Output is correct
39 Correct 124 ms 604 KB Output is correct
40 Correct 64 ms 604 KB Output is correct
41 Correct 68 ms 608 KB Output is correct
42 Correct 65 ms 604 KB Output is correct
43 Correct 34 ms 604 KB Output is correct
44 Correct 53 ms 604 KB Output is correct
45 Correct 89 ms 604 KB Output is correct
46 Correct 119 ms 600 KB Output is correct
47 Correct 52 ms 604 KB Output is correct
48 Correct 60 ms 604 KB Output is correct
49 Correct 100 ms 604 KB Output is correct
50 Correct 153 ms 600 KB Output is correct
51 Correct 51 ms 604 KB Output is correct
52 Correct 72 ms 616 KB Output is correct
53 Correct 104 ms 604 KB Output is correct
54 Correct 171 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 504 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Runtime error 1 ms 604 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 504 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 158 ms 556 KB Output is correct
30 Correct 195 ms 600 KB Output is correct
31 Correct 129 ms 604 KB Output is correct
32 Correct 71 ms 604 KB Output is correct
33 Correct 45 ms 616 KB Output is correct
34 Correct 163 ms 860 KB Output is correct
35 Correct 175 ms 604 KB Output is correct
36 Correct 35 ms 604 KB Output is correct
37 Correct 99 ms 604 KB Output is correct
38 Correct 55 ms 600 KB Output is correct
39 Correct 124 ms 604 KB Output is correct
40 Correct 64 ms 604 KB Output is correct
41 Correct 68 ms 608 KB Output is correct
42 Correct 65 ms 604 KB Output is correct
43 Correct 34 ms 604 KB Output is correct
44 Correct 53 ms 604 KB Output is correct
45 Correct 89 ms 604 KB Output is correct
46 Correct 119 ms 600 KB Output is correct
47 Correct 52 ms 604 KB Output is correct
48 Correct 60 ms 604 KB Output is correct
49 Correct 100 ms 604 KB Output is correct
50 Correct 153 ms 600 KB Output is correct
51 Correct 51 ms 604 KB Output is correct
52 Correct 72 ms 616 KB Output is correct
53 Correct 104 ms 604 KB Output is correct
54 Correct 171 ms 860 KB Output is correct
55 Runtime error 1 ms 604 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 504 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 158 ms 556 KB Output is correct
30 Correct 195 ms 600 KB Output is correct
31 Correct 129 ms 604 KB Output is correct
32 Correct 71 ms 604 KB Output is correct
33 Correct 45 ms 616 KB Output is correct
34 Correct 163 ms 860 KB Output is correct
35 Correct 175 ms 604 KB Output is correct
36 Correct 35 ms 604 KB Output is correct
37 Correct 99 ms 604 KB Output is correct
38 Correct 55 ms 600 KB Output is correct
39 Correct 124 ms 604 KB Output is correct
40 Correct 64 ms 604 KB Output is correct
41 Correct 68 ms 608 KB Output is correct
42 Correct 65 ms 604 KB Output is correct
43 Correct 34 ms 604 KB Output is correct
44 Correct 53 ms 604 KB Output is correct
45 Correct 89 ms 604 KB Output is correct
46 Correct 119 ms 600 KB Output is correct
47 Correct 52 ms 604 KB Output is correct
48 Correct 60 ms 604 KB Output is correct
49 Correct 100 ms 604 KB Output is correct
50 Correct 153 ms 600 KB Output is correct
51 Correct 51 ms 604 KB Output is correct
52 Correct 72 ms 616 KB Output is correct
53 Correct 104 ms 604 KB Output is correct
54 Correct 171 ms 860 KB Output is correct
55 Runtime error 1 ms 604 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -