제출 #967236

#제출 시각아이디문제언어결과실행 시간메모리
967236jadai007Alternating Heights (CCO22_day1problem1)C++14
25 / 25
607 ms11960 KiB
#include<bits/stdc++.h> using namespace std; int n,k,q, arr[3030], vis[3030], ans[3030], ck; vector<int> vc[3030]; int check(int u){ vis[u] = 1; for (int v : vc[u]) if(vis[v] == 1 || !vis[v] && check(v)) return 1; vis[u] = 2; return 0; } int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n >> k >> q; for(int i = 1; i<=n; ++i) cin >> arr[i]; for(int i = 1; i<=n; ++i){ int l = i, r = n; ans[i] = i; while(l <= r){ int mid = (l + r) >> 1, ck = 1; memset(vis, 0, sizeof(vis)); for(int j = 1; j<=k; ++j) vc[j].clear(); for(int j = i; j<mid; ++j){ if(j&1) vc[arr[j+1]].push_back(arr[j]); else vc[arr[j]].push_back(arr[j+1]); } for(int j = i; j<=mid; ++j){ if(!vis[arr[j]] && check(arr[j])){ ck = 0; break; } } if(ck){ ans[i] = mid; l = mid+1; } else r = mid - 1; } } while(q--){ int l, r; cin >> l >> r; ans[l] >= r ? cout << "YES\n": cout << "NO\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int check(int)':
Main.cpp:10:51: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   10 |     for (int v : vc[u]) if(vis[v] == 1 || !vis[v] && check(v)) return 1;
      |                                           ~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...