# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832674 | Theo830 | Comparing Plants (IOI20_plants) | C++17 | 1 ms | 312 KiB |
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>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define f(i,a,b) for(ll i = a;i < b;i++)
ll arr[200005];
const ll INF = 1e9;
void init(int k,vector<int>r){
ll n = r.size();
ll cur = n;
while(1){
vector<ll>possible;
f(i,0,n){
if(r[i] == 0){
possible.pb(i);
}
}
if(possible.empty()){
break;
}
ll siz = possible.size();
bool ok[siz];
vector<ll>kame;
f(i,0,siz){
ll dist = possible[(i+1)%siz] - possible[i];
if(dist <= 0){
dist += n;
}
if(dist >= k){
kame.pb(possible[i]);
}
}
for(auto x:kame){
arr[x] = cur;
r[x] = INF;
ll s = k;
ll pos = x;
while(s--){
r[pos]--;
pos--;
if(pos < 0){
pos += n;
}
}
}
cur--;
}
return;
}
int compare_plants(int x, int y) {
if(arr[x] == arr[y]){
return 0;
}
if(arr[x] > arr[y]){
return 1;
}
return -1;
}
Compilation message (stderr)
# | 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... |