답안 #858295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858295 2023-10-08T03:44:27 Z Trisanu_Das Joker (BOI20_joker) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

vector<int> adj[200005];
vector<pair<int, int> > arr[200005];
int color[200005], ans[200005], a[200005], b[200005], n, m, q;

int dfs(int u, int c) {
    if(color[x]) {
        if(c == color[x]) return 0;
        else return 1;
    }
    color[u] = c;
    for(auto v : adj[u]) if(dfs(v, 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(NULL);
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++) cin >> a[i] >> b[i];
    for(int e = 0; e < q; i++) {
        int l, r;
        cin >> l >> r;
        arr[l - 1].push_back({r - 1, e});
    }
    for(int i = 0; i < m; 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 dfs(int, int)':
Joker.cpp:9:14: error: 'x' was not declared in this scope
    9 |     if(color[x]) {
      |              ^
Joker.cpp:14:40: error: 'col' was not declared in this scope; did you mean 'cosl'?
   14 |     for(auto v : adj[u]) if(dfs(v, 3 - col)) return 1;
      |                                        ^~~
      |                                        cosl
Joker.cpp: In function 'int main()':
Joker.cpp:31:27: error: 'i' was not declared in this scope
   31 |     for(int e = 0; e < q; i++) {
      |                           ^
Joker.cpp:40:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |             int mid = l + r >> 1;
      |                       ~~^~~
Joker.cpp:45: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]
   45 |         for(int j = l; j < arr[i].size(); j++) ans[arr[i][j].second] = 0;
      |                        ~~^~~~~~~~~~~~~~~