#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
#define conts continue
#define sz(a) (int)a.size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; ++i)
#define trav(i,a) for(auto &i : a)
template<typename T>
void amin(T &x, T y){
x = min(x,y);
}
template<typename T>
void amax(T &x, T y){
x = max(x,y);
}
template<typename A,typename B>
string to_string(pair<A,B> p);
string to_string(const string &s){
return "'"+s+"'";
}
string to_string(const char* s){
return to_string((string)s);
}
string to_string(bool b){
return b?"true":"false";
}
template<typename A>
string to_string(A v){
string res = "{";
trav(x,v){
res += to_string(x)+",";
}
if(res.back() == ',') res.pop_back();
res += "}";
return res;
}
template<typename A,typename B>
string to_string(pair<A,B> p){
return "("+to_string(p.ff)+","+to_string(p.ss)+")";
}
#define debug(x) cout << "[" << #x << "]: "; cout << to_string(x) << endl
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const int inf1 = 1e9 + 5;
const ll inf2 = (ll)1e18 + 5;
#include "plants.h"
vector<int> id(N);
void init(int k, std::vector<int> a) {
k--;
int n = sz(a);
vector<bool> rem(n);
int iter = 0;
while(count(all(rem),0)){
iter++;
vector<int> zeros;
rep(i,n){
if(rem[i]) conts;
if(!a[i]){
zeros.pb(i);
}
}
vector<bool> bad(n,1);
trav(i,zeros) bad[i] = 0;
trav(i,zeros){
int j = i+1;
rep1(x,k){
bad[j] = 1;
j = (j+1)%n;
}
}
zeros.clear();
rep(i,n){
if(!bad[i]){
zeros.pb(i);
}
}
assert(!zeros.empty());
trav(i,zeros){
rem[i] = 1;
id[i] = iter;
int j = i-1;
rep1(x,k){
j = (j%n+n)%n;
a[j]--;
j--;
}
}
}
}
int compare_plants(int x, int y) {
if(id[x] < id[y]) return 1;
if(id[x] > id[y]) return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
0 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1268 KB |
Output is correct |
6 |
Correct |
15 ms |
1344 KB |
Output is correct |
7 |
Correct |
365 ms |
5972 KB |
Output is correct |
8 |
Correct |
2 ms |
1112 KB |
Output is correct |
9 |
Correct |
15 ms |
1116 KB |
Output is correct |
10 |
Correct |
358 ms |
5748 KB |
Output is correct |
11 |
Execution timed out |
4057 ms |
5468 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
0 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1268 KB |
Output is correct |
6 |
Correct |
15 ms |
1344 KB |
Output is correct |
7 |
Correct |
365 ms |
5972 KB |
Output is correct |
8 |
Correct |
2 ms |
1112 KB |
Output is correct |
9 |
Correct |
15 ms |
1116 KB |
Output is correct |
10 |
Correct |
358 ms |
5748 KB |
Output is correct |
11 |
Execution timed out |
4057 ms |
5468 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
46 ms |
5600 KB |
Output is correct |
4 |
Execution timed out |
4074 ms |
8936 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
0 ms |
1116 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |