Submission #914290

#TimeUsernameProblemLanguageResultExecution timeMemory
914290AmrJoker (BOI20_joker)C++14
0 / 100
2016 ms25728 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=3e5+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) { if(vis[x]) { if(dp[x]%2==dp[par]%2) return 1; return 0; } dp[x] = dp[par]+1; vis[x] = 1; 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(); 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); } } if(dfs(1,0)) 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:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < v[x].sz; i++)
      |                      ^
Joker.cpp:45:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |     for(int i = 0; i < v[x].sz; i++)
      |     ^~~
Joker.cpp:47:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |         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...