답안 #925656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925656 2024-02-12T06:59:30 Z vjudge1 Joker (BOI20_joker) C++17
0 / 100
5 ms 604 KB
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define no1 cout<<"-1\n"

using namespace std;

const int N = 3000;
const int M = 2e5+100;
const int INF = 1e18;
const int mod = 998244353;
  
// int binpow (int a, int n) {
// 	if (n == 0)
// 		return 1;
// 	if (n % 2 == 1)
// 		return (binpow (a, n-1) * a)%mod;
// 	else {
// 		int b = binpow (a, n/2) % mod;
// 		return (b * b)%mod;
// 	}
// }

int n,m,q;
vector<int> g[N];
vector<pair<int,int>> edges;
int d[N];
bool was[N];
map<pair<int,int>,bool> del;
bool ok;

void dfs(int v, int p = 0){
    was[v] = 1;
    d[v] = d[p]+1;
    for(auto to:g[v]){
        if(del[{to,v}]) continue;
        if(!was[to]) dfs(to,v);
        if(was[to] && (d[v]-d[to])%2 == 0) ok = 1;
    }
}

void solve(){
    cin>>n>>m>>q;
    for(int i = 1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        edges.pb({u,v});
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        del.clear();
        for(int i = 1;i<=n;i++){
            was[i] = 0;
            d[i] = 0;
        }
        ok = 0;
        for(int i = l-1;i<r;i++){
            del[{edges[i].ff,edges[i].ss}] = 1;
            del[{edges[i].ss,edges[i].ff}] = 1;
        }
        for(int i = 1;i<=n;i++){
            if(!was[i]){
                dfs(i);
                break;
            }
        }
        if(ok) yes;
        else no;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    int t = 1; 
    // cin>>t;
    //   cout<<"";
    for(int i = 1;i<=t;i++){
        solve();
        // cout<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 5 ms 572 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 5 ms 572 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 5 ms 572 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 5 ms 572 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 5 ms 572 KB Output isn't correct
9 Halted 0 ms 0 KB -