# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638574 | 2022-09-06T12:12:08 Z | morasha3 | Alternating Heights (CCO22_day1problem1) | C++17 | 1000 ms | 4400 KB |
#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]; bool dfs(vector<vector<int>>& v) { int n = v.size(); vector<int> deg(n); for (int a = 0; a < n; a++) for (int b : v[a]) deg[b]++; vector<int> q; q.reserve(n); for (int i = 0; i < n; i++) if (deg[i] == 0) q.push_back(i); for (int rep = 0; rep < q.size(); rep++) { int c = q[rep]; for (auto nxt : v[c]) { deg[nxt]--; if (deg[nxt] == 0) q.push_back(nxt); } } return n>q.size(); } 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]=i; for(int h:{0,1}) { for(int i=h; i<n; i+=2) { ll r=i+1,c=0; while(r<n) { vector<vector<ll>>adj(k); for(int j=i; j<r; j++) { if (j % 2 == i % 2) adj[arr[j]-1].push_back(arr[j + 1]-1); else adj[arr[j + 1]-1].push_back(arr[j]-1); } if(dfs(adj)) break; r++; } m[i]=r-1; } } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 223 ms | 3404 KB | Output is correct |
2 | Correct | 170 ms | 3276 KB | Output is correct |
3 | Correct | 168 ms | 3240 KB | Output is correct |
4 | Correct | 136 ms | 3296 KB | Output is correct |
5 | Correct | 147 ms | 3432 KB | Output is correct |
6 | Correct | 168 ms | 3252 KB | Output is correct |
7 | Correct | 184 ms | 3320 KB | Output is correct |
8 | Correct | 212 ms | 3332 KB | Output is correct |
9 | Correct | 760 ms | 3396 KB | Output is correct |
10 | Execution timed out | 1081 ms | 340 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 161 ms | 3352 KB | Output is correct |
2 | Correct | 158 ms | 3312 KB | Output is correct |
3 | Correct | 159 ms | 3284 KB | Output is correct |
4 | Correct | 145 ms | 4236 KB | Output is correct |
5 | Correct | 151 ms | 3452 KB | Output is correct |
6 | Correct | 156 ms | 3280 KB | Output is correct |
7 | Correct | 176 ms | 3396 KB | Output is correct |
8 | Correct | 153 ms | 3328 KB | Output is correct |
9 | Correct | 209 ms | 3776 KB | Output is correct |
10 | Correct | 463 ms | 4400 KB | Output is correct |
11 | Correct | 474 ms | 4276 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Execution timed out | 1092 ms | 436 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 223 ms | 3404 KB | Output is correct |
2 | Correct | 170 ms | 3276 KB | Output is correct |
3 | Correct | 168 ms | 3240 KB | Output is correct |
4 | Correct | 136 ms | 3296 KB | Output is correct |
5 | Correct | 147 ms | 3432 KB | Output is correct |
6 | Correct | 168 ms | 3252 KB | Output is correct |
7 | Correct | 184 ms | 3320 KB | Output is correct |
8 | Correct | 212 ms | 3332 KB | Output is correct |
9 | Correct | 760 ms | 3396 KB | Output is correct |
10 | Execution timed out | 1081 ms | 340 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |