Submission #914293

#TimeUsernameProblemLanguageResultExecution timeMemory
914293AmrJoker (BOI20_joker)C++14
14 / 100
114 ms856 KiB
#include <bits/stdc++.h> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define S second #define F first #define all(x) (x).begin(),(x).end() #define sz size() #define Yes cout << "YES" << endl #define No cout << "NO" << endl #define pb(x) push_back(x); #define endl '\n' #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N=2e3+7; ll INF=INT_MAX,mod=1e9+7; int TT=1; ll power(ll x, unsigned int y) { ll res = 1; x = x; // % mod; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res*x) ; // % mod; y = y>>1; x = (x*x) ; // % mod; } return res; } vector<ll> v[N]; ll dp[N]; ll vis[N]; pair<ll,ll> a[N]; bool dfs(ll x, ll par) { bool cnt = 1; if(vis[x]==cnt) { if(dp[x]%2==dp[par]%2) return 1; return 0; } dp[x] = dp[par]+1; vis[x] = cnt; bool ok = 0; for(int i = 0; i < v[x].sz; i++) if(v[x][i]!=par) ok|=dfs(v[x][i],x); return ok; } ll n , m , q; void solve() { cin >> n >> m >> q; for(int i = 1; i <= m; i++) { ll x, y; cin >> x >> y; a[i] = {x,y}; } while(q--) { ll l , r; cin >> l >> r; for(int i = 1; i < N; i++) v[i].clear(); dp[0] = 0; memset(vis,0,sizeof vis); for(int i = 1; i <= m; i++) { if(i<l||i>r) { v[a[i].F].push_back(a[i].S); v[a[i].S].push_back(a[i].F); } } bool ok = 0; for(int i = 1; i <= n; i++) { if(vis[i]==0) ok|=dfs(i,0); } if(ok) cout << "YES" << endl; else cout << "NO" << endl; } } int main(){ //freopen("friday.in","r",stdin); //freopen("friday.out","w",stdout); fast; // cin >> TT; while(TT--) solve(); return 0; }

Compilation message (stderr)

Joker.cpp: In function 'bool dfs(ll, ll)':
Joker.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < v[x].sz; i++)
      |                      ^
Joker.cpp:46:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |     for(int i = 0; i < v[x].sz; i++)
      |     ^~~
Joker.cpp:48:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   48 |         return ok;
      |         ^~~~~~
#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...