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"
//Bismillahirrahmanirrahim
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=0;i<n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int m,b[li],a[li],flag,t,siz[li],say,vis[li],dep[li],kk;
int cev;
string s;
vector<int> v[li],vv;
inline void dfs(int node,int der){
if(vis[node])return;
vis[node]=say;
dep[node]=der;
for(int i=0;i<(int)v[node].size();i++){
int go=v[node][i];
dfs(go,der+1);
}
}
void init(int k, std::vector<int> r) {
for(int i=0;i<(int)r.size();i++){
if(r[i]==1){
v[(i+1)%(int)r.size()].pb(i);
siz[i]++;
}
}
//~ queue<int>
int n=(int)r.size();
FOR{
if(siz[i]==0){
say++;
dfs(i,0);
}
}
vv=r;
kk=k;
}
int compare_plants(int x, int y) {
if(vv[x]<vv[y])return 1;
if(vv[x]>vv[y])return -1;
if(vv[x]==vv[y]){
if((x+kk-1)%(int)vv.size()>=y)return -1;
else return 1;
}
if(vis[x]!=vis[y])return 0;
if(dep[x]>dep[y])return -1;
return 1;
}
# | 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... |