Submission #1093509

#TimeUsernameProblemLanguageResultExecution timeMemory
1093509duyhoanhoJoker (BOI20_joker)C++17
0 / 100
1 ms860 KiB
#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 = 2e3+10; int n,m,q,fre[N]; bool ok; pii a[N]; vector<int> ad[N]; void bfs(int x) { queue<int> q; fre[x] = 0; q.push(x); while(q.size()) { int u = q.front();q.pop(); for(int v : ad[u]) { if(fre[v] == fre[u]) { ok = 1; return; } if(fre[v] != -1) continue; fre[v] = 1 - fre[u]; q.push(v); } } } bool qu(int l,int r) { 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) { bfs(i); 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 (stderr)

Joker.cpp: In function 'int32_t main()':
Joker.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen("task.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen("task.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...