#include <iostream>
#include <vector>
#include <set>
#include "plants.h"
#define INF 1000000007
using namespace std;
int n;
set<int> zero;
set<int> cur;
set<int>:: iterator it, it2;
int ans[200001];
void init(int k, vector<int> r)
{
int i, j;
n=r.size();
for(i=0;i<n;i++)
if(r[i]==0)
zero.insert(i);
for(i=1;i<=n;i++){
cur.clear();
it=zero.begin();
while(it!=zero.end()){
cur.insert(*it), cur.insert(*it+n);
it++;
}
it=cur.begin();
while(it!=cur.end()){
it2=it, it2++;
if(it2==cur.end())
break;
if(*it2-*it<k){
cur.erase(*it2);
cur.erase(*it2+n);
}
it++;
}
it=cur.begin();
while(it!=cur.end()){
int f=*it;
if(f<n)
continue;
f-=n;
ans[f]=i;
zero.erase(f), zero.erase(f+n);
for(j=1;j<k;j++){
r[f+j]--;
if(r[f+j]==0)
zero.insert(f+j);
}
it++;
}
}
}
int compare_plants(int x, int y)
{
if(ans[x]==ans[y])
return 0;
else if(ans[x]>ans[y])
return 1;
return -1;
}
//int main()
//{
// init(2, {1, 0, 1, 0});
// cout << compare_plants(1, 2) << endl;
// cout << compare_plants(1, 3) << endl;
// cout << compare_plants(1, 4) << endl;
// cout << compare_plants(2, 3) << endl;
// cout << compare_plants(2, 4) << endl;
// cout << compare_plants(3, 4) << endl;
//
// return 0;
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4075 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4064 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4064 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4062 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4057 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4081 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4075 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |