답안 #759305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759305 2023-06-16T05:33:08 Z vjudge1 Joker (BOI20_joker) C++17
31 / 100
2000 ms 26776 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 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 4 ms 10452 KB Output is correct
5 Correct 5 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 10452 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 7 ms 10452 KB Output is correct
12 Correct 8 ms 10532 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 7 ms 10452 KB Output is correct
15 Correct 7 ms 10536 KB Output is correct
16 Correct 7 ms 10484 KB Output is correct
17 Correct 9 ms 10532 KB Output is correct
18 Correct 7 ms 10532 KB Output is correct
19 Correct 7 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 7 ms 10532 KB Output is correct
22 Correct 7 ms 10532 KB Output is correct
23 Correct 7 ms 10452 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 10 ms 10452 KB Output is correct
26 Correct 9 ms 10452 KB Output is correct
27 Correct 7 ms 10452 KB Output is correct
28 Correct 7 ms 10452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 4 ms 10452 KB Output is correct
5 Correct 5 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 10452 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 7 ms 10452 KB Output is correct
12 Correct 8 ms 10532 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 7 ms 10452 KB Output is correct
15 Correct 7 ms 10536 KB Output is correct
16 Correct 7 ms 10484 KB Output is correct
17 Correct 9 ms 10532 KB Output is correct
18 Correct 7 ms 10532 KB Output is correct
19 Correct 7 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 7 ms 10532 KB Output is correct
22 Correct 7 ms 10532 KB Output is correct
23 Correct 7 ms 10452 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 10 ms 10452 KB Output is correct
26 Correct 9 ms 10452 KB Output is correct
27 Correct 7 ms 10452 KB Output is correct
28 Correct 7 ms 10452 KB Output is correct
29 Correct 17 ms 10580 KB Output is correct
30 Incorrect 13 ms 10636 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 114 ms 22768 KB Output is correct
4 Correct 310 ms 26356 KB Output is correct
5 Correct 100 ms 20760 KB Output is correct
6 Correct 124 ms 23244 KB Output is correct
7 Correct 123 ms 22376 KB Output is correct
8 Correct 120 ms 23436 KB Output is correct
9 Correct 144 ms 23880 KB Output is correct
10 Correct 169 ms 24272 KB Output is correct
11 Correct 129 ms 22120 KB Output is correct
12 Correct 177 ms 23336 KB Output is correct
13 Correct 101 ms 21460 KB Output is correct
14 Correct 135 ms 23032 KB Output is correct
15 Correct 149 ms 23216 KB Output is correct
16 Correct 188 ms 23572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 4 ms 10452 KB Output is correct
5 Correct 5 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 10452 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 7 ms 10452 KB Output is correct
12 Correct 8 ms 10532 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 7 ms 10452 KB Output is correct
15 Correct 7 ms 10536 KB Output is correct
16 Correct 7 ms 10484 KB Output is correct
17 Correct 9 ms 10532 KB Output is correct
18 Correct 7 ms 10532 KB Output is correct
19 Correct 7 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 7 ms 10532 KB Output is correct
22 Correct 7 ms 10532 KB Output is correct
23 Correct 7 ms 10452 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 10 ms 10452 KB Output is correct
26 Correct 9 ms 10452 KB Output is correct
27 Correct 7 ms 10452 KB Output is correct
28 Correct 7 ms 10452 KB Output is correct
29 Correct 114 ms 22768 KB Output is correct
30 Correct 310 ms 26356 KB Output is correct
31 Correct 100 ms 20760 KB Output is correct
32 Correct 124 ms 23244 KB Output is correct
33 Correct 123 ms 22376 KB Output is correct
34 Correct 120 ms 23436 KB Output is correct
35 Correct 144 ms 23880 KB Output is correct
36 Correct 169 ms 24272 KB Output is correct
37 Correct 129 ms 22120 KB Output is correct
38 Correct 177 ms 23336 KB Output is correct
39 Correct 101 ms 21460 KB Output is correct
40 Correct 135 ms 23032 KB Output is correct
41 Correct 149 ms 23216 KB Output is correct
42 Correct 188 ms 23572 KB Output is correct
43 Execution timed out 2066 ms 26776 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 4 ms 10452 KB Output is correct
5 Correct 5 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 10452 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 7 ms 10452 KB Output is correct
12 Correct 8 ms 10532 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 7 ms 10452 KB Output is correct
15 Correct 7 ms 10536 KB Output is correct
16 Correct 7 ms 10484 KB Output is correct
17 Correct 9 ms 10532 KB Output is correct
18 Correct 7 ms 10532 KB Output is correct
19 Correct 7 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 7 ms 10532 KB Output is correct
22 Correct 7 ms 10532 KB Output is correct
23 Correct 7 ms 10452 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 10 ms 10452 KB Output is correct
26 Correct 9 ms 10452 KB Output is correct
27 Correct 7 ms 10452 KB Output is correct
28 Correct 7 ms 10452 KB Output is correct
29 Correct 17 ms 10580 KB Output is correct
30 Incorrect 13 ms 10636 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10464 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 5 ms 10452 KB Output is correct
4 Correct 4 ms 10452 KB Output is correct
5 Correct 5 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 10452 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 7 ms 10452 KB Output is correct
12 Correct 8 ms 10532 KB Output is correct
13 Correct 7 ms 10452 KB Output is correct
14 Correct 7 ms 10452 KB Output is correct
15 Correct 7 ms 10536 KB Output is correct
16 Correct 7 ms 10484 KB Output is correct
17 Correct 9 ms 10532 KB Output is correct
18 Correct 7 ms 10532 KB Output is correct
19 Correct 7 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 7 ms 10532 KB Output is correct
22 Correct 7 ms 10532 KB Output is correct
23 Correct 7 ms 10452 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 10 ms 10452 KB Output is correct
26 Correct 9 ms 10452 KB Output is correct
27 Correct 7 ms 10452 KB Output is correct
28 Correct 7 ms 10452 KB Output is correct
29 Correct 17 ms 10580 KB Output is correct
30 Incorrect 13 ms 10636 KB Output isn't correct
31 Halted 0 ms 0 KB -