답안 #1093518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1093518 2024-09-27T02:00:51 Z duyhoanho Joker (BOI20_joker) C++14
0 / 100
402 ms 262144 KB
#include<bits/stdc++.h>
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
using namespace std;
const int N = 2e5+10;
int n,m,q,fre[N];

pii a[N];
vector<int> ad[N];
bool qu(int l,int r)
{
    bool ok = 0;
    forinc(i,1,m)
    {
        if(l<=i && i<=r) continue;
        int x,y;
        tie(x,y) = a[i];
        ad[x].pb(y);
        ad[y].pb(x);
    }

    for(int i=1; i<=n; i++) fre[i] = -1;
    for(int i=1; i<=n; i++)
    {
        if(fre[i] == -1)
        {
            queue<int> q;
            q.push(i);
            fre[i] = 0;
            while(q.size())
            {
                int u = q.front();q.pop();
                for(int v:ad[u])
                {
                    if(fre[v] == fre[u]) return true;
                    if(fre[v] != -1) continue;
                    fre[v] = 1 - fre[u];
                    q.push(v);
                }

            }
            //if(ok == 1) return true;
        }
    }
    return false;
}
int32_t main()
{
    if(fopen("task.inp","r"))
    {
        freopen("task.inp","r",stdin);
        freopen("task.out","w",stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>q;
    forinc(i,1,m)
    {
        int x,y;
        cin>>x>>y;
        a[i] = {x,y};
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<< (qu(l,r) ? "YES\n" : "NO\n");
    }


}

Compilation message

Joker.cpp: In function 'bool qu(long long int, long long int)':
Joker.cpp:16:10: warning: unused variable 'ok' [-Wunused-variable]
   16 |     bool ok = 0;
      |          ^~
Joker.cpp: In function 'int32_t main()':
Joker.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("task.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen("task.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Runtime error 402 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -