Submission #638507

#TimeUsernameProblemLanguageResultExecution timeMemory
638507morasha3Alternating Heights (CCO22_day1problem1)C++17
6 / 25
1091 ms13064 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; typedef double ld; const ll mod=1e9+7; #define endl '\n' ll n,k,q,arr[3007],vis[3007],s[3007]; vector<vector<ll>>v(3007); bool f=0; void dfs(ll idx) { vis[idx]=1; s[idx]=1; for(int i=0; i<v[idx].size(); i++) { if(vis[v[idx][i]]&&s[v[idx][i]]) { f=1; break; } else if(vis[v[idx][i]]) continue; dfs(v[idx][i]); } s[idx]=0; } int32_t main() { //freopen("jumping.in","r",stdin); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k>>q; for(int i=0; i<n; i++) cin>>arr[i]; ll m[n]; for(int i=0; i<n; i++) { m[i]=0; ll c=0; for(int j=i+1; j<n; j++) { if(c==0) { c++; v[arr[j]-1].push_back(arr[j-1]-1); } else { c=0; v[arr[j-1]-1].push_back(arr[j]-1); } f=0; for(int i=0; i<k; i++) vis[i]=0; for(int i=0; i<k; i++) { if(vis[i]==0) dfs(i); } if(f) { m[i]=j-1; break; } } if(f==0) m[i]=n-1; for(int i=0;i<k;i++)v[i].clear(); } while(q--) { ll a,b; cin>>a>>b; a--,b--; if(m[a]>=b) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void dfs(ll)':
Main.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0; i<v[idx].size(); i++)
      |                  ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...