Submission #1029959

# Submission time Handle Problem Language Result Execution time Memory
1029959 2024-07-21T14:45:29 Z happy_node Comparing Plants (IOI20_plants) C++17
14 / 100
139 ms 11980 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

const int MX=5005;

bool vis[MX];

int N;

vector<int> ord, rev;

void init(int k, std::vector<int> r) {
	N=r.size();

	vector<int> pos;
	for(int i=0;i<N;i++) 
		if(!r[i]) pos.push_back(i);

	for(int i=0;i<N;i++) {
		int p=-1;
		for(int j=0;j+1<pos.size();j++) {
			if(pos[j+1]-pos[j]>=k) {
				p=pos[j+1];
			}
		}
		if(p==-1) p=pos[0];

		ord.push_back(p);

		for(int j=0;j<k;j++) {
			int np=p-j;
			if(np<0) np+=N;
			if(vis[np]) continue;
			r[np]-=1;
		}

		vis[p]=1;

		vector<int> npos;
		for(int j=0;j<N;j++) {
			if(vis[j]) continue;
			if(r[j]==0) npos.push_back(j);
		}

		swap(pos,npos);
	}
	rev.assign(N,0);
	for(int i=0;i<N;i++) rev[ord[i]]=i;	
}

int compare_plants(int x, int y) {
	if(rev[x]<rev[y]) return 1;
	return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int j=0;j+1<pos.size();j++) {
      |               ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 5 ms 600 KB Output is correct
7 Correct 139 ms 5204 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 452 KB Output is correct
10 Correct 114 ms 5232 KB Output is correct
11 Correct 102 ms 4948 KB Output is correct
12 Correct 82 ms 5200 KB Output is correct
13 Correct 122 ms 5200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 5 ms 600 KB Output is correct
7 Correct 139 ms 5204 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 452 KB Output is correct
10 Correct 114 ms 5232 KB Output is correct
11 Correct 102 ms 4948 KB Output is correct
12 Correct 82 ms 5200 KB Output is correct
13 Correct 122 ms 5200 KB Output is correct
14 Runtime error 48 ms 7724 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 444 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 64 ms 4828 KB Output is correct
4 Runtime error 57 ms 11980 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -