Submission #431115

# Submission time Handle Problem Language Result Execution time Memory
431115 2021-06-17T09:46:00 Z Pbezz Comparing Plants (IOI20_plants) C++14
14 / 100
4000 ms 6020 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;

const ll MAXN = 2e5+5;
const ll INF = 1e9+7;

ll order[MAXN],n;

void init(int k, std::vector<int> r) {

	ll l,i,cur,n=(ll)r.size();
	for(l=n;l>=1;l--){//find current maximum
	vector<ll>meh;//cout<<l<<"\n";

	for(i=0;i<n;i++){//cout<<r[i]<<" ";
	if(r[i]==0)meh.pb(i);
	}
	if((int)meh.size()==0)break;
	if((int)meh.size()==1){
	cur=meh[0];
	}else{

	for(i=1;i<(ll)meh.size();i++){
	if(meh[i]-meh[i-1]>=k){
	cur=meh[i]; break;
	}
	}

	if(n-meh[meh.size()-1]+meh[0]>=k)cur=meh[0];

	}//cout<<"# ha "<<cur<<endl;
	order[cur]=l;
	r[cur]=-1;
	for(i=0;i<k-1;i++){
	cur--;
	if(cur<0)cur=n-1;

	r[cur]--;
	}

//cout<<l<<" "<<2<<endl;
}

	//for(ll i=0;i<n;i++)cout<<order[i]<<" k ";
	//cout<<endl;

	return;
}

int compare_plants(int x, int y) {




	if(order[x]>order[y])return 1;

	return -1;



	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:39:7: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |  r[cur]=-1;
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 6 ms 332 KB Output is correct
7 Correct 164 ms 3216 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 6 ms 332 KB Output is correct
10 Correct 170 ms 3188 KB Output is correct
11 Correct 163 ms 3272 KB Output is correct
12 Correct 147 ms 3264 KB Output is correct
13 Correct 158 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 6 ms 332 KB Output is correct
7 Correct 164 ms 3216 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 6 ms 332 KB Output is correct
10 Correct 170 ms 3188 KB Output is correct
11 Correct 163 ms 3272 KB Output is correct
12 Correct 147 ms 3264 KB Output is correct
13 Correct 158 ms 3192 KB Output is correct
14 Correct 1451 ms 3336 KB Output is correct
15 Execution timed out 4046 ms 5844 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 74 ms 3052 KB Output is correct
4 Execution timed out 4035 ms 6020 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -