답안 #255911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255911 2020-08-02T05:32:34 Z 반딧불(#5032) Joker (BOI20_joker) C++17
0 / 100
2000 ms 14224 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;

struct dat{
    int s, e, i;
    dat(){}
    dat(int s, int e, int i): s(s), e(e), i(i){}
};
vector<dat> link[200002];

int n, m, q;
int l, r;

int chk[200002];

bool dfs(int x, int y = 1){
    chk[x] = y;
    for(auto &nxt: link[x]){
        if(l <= nxt.i && nxt.i <= r) continue;
        if(chk[nxt.e] == y) return true;
        if(chk[nxt.e] == 0) dfs(nxt.e, 3-y);
    }
    return false;
}

int main(){
    scanf("%d %d %d", &n, &m, &q);
    for(int i=1; i<=m; i++){
        int s, e;
        scanf("%d %d", &s, &e);
        link[s].push_back(dat(s, e, i));
        link[e].push_back(dat(e, s, i));
    }

    for(int i=1; i<=q; i++){
        scanf("%d %d", &l, &r);
        memset(chk, 0, sizeof(chk));

        bool possible = 0;
        for(int i=1; i<=n; i++){
            if(!chk[i] && dfs(i)){
                possible = 1;
                break;
            }
        }
        printf("%s\n", possible ? "YES" : "NO");
    }
}

Compilation message

Joker.cpp: In function 'int main()':
Joker.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &s, &e);
         ~~~~~^~~~~~~~~~~~~~~~~
Joker.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &l, &r);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Correct 3 ms 5760 KB Output is correct
4 Incorrect 3 ms 5760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Correct 3 ms 5760 KB Output is correct
4 Incorrect 3 ms 5760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Execution timed out 2090 ms 14224 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Correct 3 ms 5760 KB Output is correct
4 Incorrect 3 ms 5760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Correct 3 ms 5760 KB Output is correct
4 Incorrect 3 ms 5760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5760 KB Output is correct
2 Correct 4 ms 5760 KB Output is correct
3 Correct 3 ms 5760 KB Output is correct
4 Incorrect 3 ms 5760 KB Output isn't correct
5 Halted 0 ms 0 KB -