제출 #648618

#제출 시각아이디문제언어결과실행 시간메모리
648618mychecksedadJoker (BOI20_joker)C++17
14 / 100
1606 ms40324 KiB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 2e5+10, F = 2147483646, K = 20;


int n, m, q, l, r;
bool ok;
vector<pair<int, int>> g[N];
bitset<M> vis, pos, okb;
void dfs(int v, int p, bool c){
    vis[v] = 1;
    pos[v] = c;
    for(auto k: g[v]){
        int u = k.first;
        if(l <= k.second && k.second <= r) continue;
        if(u != p){
            if(vis[u])
                ok |= pos[v] == pos[u];
            else
                dfs(u, v, !c);
        }
    }
} 
void dfs1(int v, int p, bool c, int min_edge){
    vis[v] = 1;
    pos[v] = c;
    for(auto k: g[v]){
        int u = k.first;
        if(l <= k.second && k.second <= r) continue;
        if(u != p){
            if(vis[u])
                okb[min_edge] = okb[min_edge] | (pos[v] == pos[u]);
            else
                dfs1(u, v, !c, k.second > r ? min(min_edge, k.second) : min_edge);
        }
    }
}
void solve(){
    cin >> n >> m >> q;
    for(int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;
        g[u].pb({v, i + 1});
        g[v].pb({u, i + 1});
    }
    for(int i = 1; i <= n; ++i){
        sort(all(g[i]), [&](const pair<int, int> &a, pair<int, int> &b){
            return a.second > b.second;
        });
    }
    if(n <= 2000){
        for(int i = 0; i < q; ++i){
            cin >> l >> r;
            vis = 0;
            ok = 0;
            for(int v = 1; v <= n; ++v) if(!ok && !vis[v]) dfs(v, v, 0);
            if(ok) cout << "YES\n";
            else cout << "NO\n";
        }
    }
    else{
        vector<int> lim(205);
        for(int i = 1; i <= min(200, m); ++i){
            vis = 0;
            okb = 0;
            l = i, r = i;
            for(int v = 1; v <= n; ++v) if(!vis[v]) dfs1(v, v, 0, m + 1);
            for(int j = 1; j <= m + 1; ++j){
                if(okb[j]) lim[i] = j;
            }
        }
        for(int i = 1; i <= q; ++i){
            cin >> l >> r;
            cout << (r <= lim[l] ? "YES": "NO") << '\n';
        }
    }
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

컴파일 시 표준 에러 (stderr) 메시지

Joker.cpp: In function 'int main()':
Joker.cpp:97:16: warning: unused variable 'aa' [-Wunused-variable]
   97 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...