#include "plants.h"
#include<bits/stdc++.h>
std::vector<int> g[200001];
int ind[200001];
int ap[200001];
void ts(int n){
std::queue<int> q ;
for(int i = 0 ; i < n ; i ++)
if(ind[i] == 0)q.push(i) , ap[i] = 0;
while(!q.empty()){
for(auto &it : g[q.front()]){
ind[it] -- ;
if(ind[it] == 0)q.push(it) , ap[it] = ap[q.front()] + 1;
}
q.pop();
}
}
void init(int k, std::vector<int> r) {
// ঠিক সেই ক্ষেত্রে x = 2 ;
int n = r.size();
for(int i = 0 ; i < n ; i ++){
int nxt = (i + 1) % n ;
if(r[i] == 0)
g[i].push_back(nxt) , ind[nxt] ++ ;
else g[nxt].push_back(i) , ind[i] ++;
}
ts(n);
return;
}
int compare_plants(int x, int y) {
if(ap[x] < ap[y])return 1;
else if (ap[y] < ap[x])return -1 ;
else return 0 ;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Incorrect |
3 ms |
5004 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5000 KB |
Output is correct |
2 |
Correct |
3 ms |
5000 KB |
Output is correct |
3 |
Incorrect |
4 ms |
4944 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5000 KB |
Output is correct |
2 |
Correct |
3 ms |
5000 KB |
Output is correct |
3 |
Incorrect |
4 ms |
4944 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Incorrect |
69 ms |
9512 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4920 KB |
Output is correct |
2 |
Correct |
3 ms |
5000 KB |
Output is correct |
3 |
Incorrect |
3 ms |
5000 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Incorrect |
4 ms |
5068 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Incorrect |
3 ms |
5004 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |