This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |