답안 #759306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759306 2023-06-16T05:33:19 Z boyliguanhan Joker (BOI20_joker) C++17
31 / 100
2000 ms 22792 KB
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define N 200100
vector<int> adj[N];
vector<pair<int, int>> arr[N];
int color[N], ans[N], a[N], b[N], n, m, q;
int dfs(int x, int col) {
    if(color[x]) {
        if(col==color[x]) return 0;
        else return 1;
    }
    color[x] = col;
    for(auto i: adj[x]) 
        if(dfs(i, 3-col))
            return 1;
    return 0;
}
bool check(int l, int r) {
    memset(color, 0, sizeof color);
    for(int i = 1; i <= n; i++)
        adj[i].clear();
    for(int i = 0; i < l; i++)
        adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]);
    for(int i = r+1; i < m; i++)
        adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]);
    for(int i = 0; i < n; i++)
        if(!color[i])
            if(dfs(i, 1))
                return 1;
    return 0;
}
int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++)
        cin >> a[i] >> b[i];
    for(int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        arr[l-1].push_back({r-1,i});
    }
    for(int i = 0; i < 200; i++) {
        sort(arr[i].begin(), arr[i].end());
        int l = 0, r = arr[i].size();
        while(l<r) {
            int mid = l+r>>1;
            if(check(i, arr[i][mid].first)) {
                l = mid+1;
            } else {
                r = mid;
            }
        }
        for(int j = 0; j < l; j++)
            ans[arr[i][j].second] = 1;
        for(int j = l; j < arr[i].size(); ++j)
            ans[arr[i][j].second] = 0;
    }
    for(int i = 0; i < q; i++)
        cout << (ans[i]?"YES\n":"NO\n");
}

Compilation message

Joker.cpp: In function 'int main()':
Joker.cpp:48:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |             int mid = l+r>>1;
      |                       ~^~
Joker.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int j = l; j < arr[i].size(); ++j)
      |                        ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 5 ms 10452 KB Output is correct
5 Correct 4 ms 10452 KB Output is correct
6 Correct 5 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10452 KB Output is correct
9 Correct 7 ms 10532 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 8 ms 10452 KB Output is correct
12 Correct 8 ms 10452 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 10 ms 10420 KB Output is correct
15 Correct 7 ms 10452 KB Output is correct
16 Correct 7 ms 10528 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 7 ms 10528 KB Output is correct
19 Correct 8 ms 10580 KB Output is correct
20 Correct 7 ms 10452 KB Output is correct
21 Correct 6 ms 10528 KB Output is correct
22 Correct 7 ms 10512 KB Output is correct
23 Correct 9 ms 10472 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10532 KB Output is correct
26 Correct 7 ms 10452 KB Output is correct
27 Correct 7 ms 10464 KB Output is correct
28 Correct 7 ms 10536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 5 ms 10452 KB Output is correct
5 Correct 4 ms 10452 KB Output is correct
6 Correct 5 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10452 KB Output is correct
9 Correct 7 ms 10532 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 8 ms 10452 KB Output is correct
12 Correct 8 ms 10452 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 10 ms 10420 KB Output is correct
15 Correct 7 ms 10452 KB Output is correct
16 Correct 7 ms 10528 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 7 ms 10528 KB Output is correct
19 Correct 8 ms 10580 KB Output is correct
20 Correct 7 ms 10452 KB Output is correct
21 Correct 6 ms 10528 KB Output is correct
22 Correct 7 ms 10512 KB Output is correct
23 Correct 9 ms 10472 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10532 KB Output is correct
26 Correct 7 ms 10452 KB Output is correct
27 Correct 7 ms 10464 KB Output is correct
28 Correct 7 ms 10536 KB Output is correct
29 Correct 17 ms 10608 KB Output is correct
30 Incorrect 14 ms 10580 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 113 ms 21316 KB Output is correct
4 Correct 265 ms 22792 KB Output is correct
5 Correct 100 ms 16556 KB Output is correct
6 Correct 123 ms 19008 KB Output is correct
7 Correct 128 ms 18320 KB Output is correct
8 Correct 121 ms 20160 KB Output is correct
9 Correct 143 ms 20612 KB Output is correct
10 Correct 205 ms 20804 KB Output is correct
11 Correct 132 ms 18136 KB Output is correct
12 Correct 188 ms 19172 KB Output is correct
13 Correct 98 ms 17632 KB Output is correct
14 Correct 135 ms 18924 KB Output is correct
15 Correct 148 ms 19312 KB Output is correct
16 Correct 175 ms 19408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 5 ms 10452 KB Output is correct
5 Correct 4 ms 10452 KB Output is correct
6 Correct 5 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10452 KB Output is correct
9 Correct 7 ms 10532 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 8 ms 10452 KB Output is correct
12 Correct 8 ms 10452 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 10 ms 10420 KB Output is correct
15 Correct 7 ms 10452 KB Output is correct
16 Correct 7 ms 10528 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 7 ms 10528 KB Output is correct
19 Correct 8 ms 10580 KB Output is correct
20 Correct 7 ms 10452 KB Output is correct
21 Correct 6 ms 10528 KB Output is correct
22 Correct 7 ms 10512 KB Output is correct
23 Correct 9 ms 10472 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10532 KB Output is correct
26 Correct 7 ms 10452 KB Output is correct
27 Correct 7 ms 10464 KB Output is correct
28 Correct 7 ms 10536 KB Output is correct
29 Correct 113 ms 21316 KB Output is correct
30 Correct 265 ms 22792 KB Output is correct
31 Correct 100 ms 16556 KB Output is correct
32 Correct 123 ms 19008 KB Output is correct
33 Correct 128 ms 18320 KB Output is correct
34 Correct 121 ms 20160 KB Output is correct
35 Correct 143 ms 20612 KB Output is correct
36 Correct 205 ms 20804 KB Output is correct
37 Correct 132 ms 18136 KB Output is correct
38 Correct 188 ms 19172 KB Output is correct
39 Correct 98 ms 17632 KB Output is correct
40 Correct 135 ms 18924 KB Output is correct
41 Correct 148 ms 19312 KB Output is correct
42 Correct 175 ms 19408 KB Output is correct
43 Execution timed out 2071 ms 22472 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 5 ms 10452 KB Output is correct
5 Correct 4 ms 10452 KB Output is correct
6 Correct 5 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10452 KB Output is correct
9 Correct 7 ms 10532 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 8 ms 10452 KB Output is correct
12 Correct 8 ms 10452 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 10 ms 10420 KB Output is correct
15 Correct 7 ms 10452 KB Output is correct
16 Correct 7 ms 10528 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 7 ms 10528 KB Output is correct
19 Correct 8 ms 10580 KB Output is correct
20 Correct 7 ms 10452 KB Output is correct
21 Correct 6 ms 10528 KB Output is correct
22 Correct 7 ms 10512 KB Output is correct
23 Correct 9 ms 10472 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10532 KB Output is correct
26 Correct 7 ms 10452 KB Output is correct
27 Correct 7 ms 10464 KB Output is correct
28 Correct 7 ms 10536 KB Output is correct
29 Correct 17 ms 10608 KB Output is correct
30 Incorrect 14 ms 10580 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 5 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 5 ms 10452 KB Output is correct
5 Correct 4 ms 10452 KB Output is correct
6 Correct 5 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10452 KB Output is correct
9 Correct 7 ms 10532 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 8 ms 10452 KB Output is correct
12 Correct 8 ms 10452 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 10 ms 10420 KB Output is correct
15 Correct 7 ms 10452 KB Output is correct
16 Correct 7 ms 10528 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 7 ms 10528 KB Output is correct
19 Correct 8 ms 10580 KB Output is correct
20 Correct 7 ms 10452 KB Output is correct
21 Correct 6 ms 10528 KB Output is correct
22 Correct 7 ms 10512 KB Output is correct
23 Correct 9 ms 10472 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10532 KB Output is correct
26 Correct 7 ms 10452 KB Output is correct
27 Correct 7 ms 10464 KB Output is correct
28 Correct 7 ms 10536 KB Output is correct
29 Correct 17 ms 10608 KB Output is correct
30 Incorrect 14 ms 10580 KB Output isn't correct
31 Halted 0 ms 0 KB -