Submission #317529

# Submission time Handle Problem Language Result Execution time Memory
317529 2020-10-30T01:45:26 Z arnold518 Comparing Plants (IOI20_plants) C++14
14 / 100
277 ms 8440 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 5000;
const int INF = 1e9;

int N, K, R[MAXN+10], H[MAXN+10];

void init(int _K, vector<int> _R)
{
	K=_K; N=_R.size();
	for(int i=0; i<N; i++) R[i]=_R[i];

	for(int i=N-1; i>=0; i--)
	{
		vector<int> V;
		for(int j=0; j<N; j++) if(R[j]==0) V.push_back(j);
		//for(int j=0; j<N; j++) printf("%d ", R[j]); printf("\n");

		for(int j=0; j<V.size(); j++)
		{
			int p=V[j], q;
			if(j!=0) q=V[j-1];
			else q=V[V.size()-1];

			int d=(p-q+N)%N;
			if(d==0) d+=N;
			if(d>=K)
			{
				for(int k=(p-K+1+N)%N; k!=p; k=(k+1)%N) R[k]--;
				R[p]=INF;
				H[p]=i;
			}
		}
	}

	//for(int i=0; i<N; i++) printf("%d ", H[i]); printf("\n");
	return;
}

int compare_plants(int x, int y)
{
	int ans=0;
	if(H[x]>H[y]) return 1;
	if(H[x]<H[y]) return -1;
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int j=0; j<V.size(); j++)
      |                ~^~~~~~~~~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:48:6: warning: unused variable 'ans' [-Wunused-variable]
   48 |  int ans=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 257 ms 3376 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 10 ms 384 KB Output is correct
10 Correct 252 ms 3320 KB Output is correct
11 Correct 267 ms 3192 KB Output is correct
12 Correct 215 ms 3324 KB Output is correct
13 Correct 277 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 257 ms 3376 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 10 ms 384 KB Output is correct
10 Correct 252 ms 3320 KB Output is correct
11 Correct 267 ms 3192 KB Output is correct
12 Correct 215 ms 3324 KB Output is correct
13 Correct 277 ms 3192 KB Output is correct
14 Runtime error 61 ms 5624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 89 ms 3320 KB Output is correct
4 Runtime error 93 ms 8440 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -