Submission #769014

# Submission time Handle Problem Language Result Execution time Memory
769014 2023-06-29T05:03:37 Z ono_de206 Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 340 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

vector<int> a;
int n, k;

void init(int _k, vector<int> r) {
	k = _k;
	n = r.size();
	a.resize(n);
	int ls = 0;
	for(int i = n - 1; i >= 0; i--) {
		if(r[i] == 0) {
			ls = i;
			break;
		}
	}
	int now = ls;
	for(int i = 0; i < n; i++) {
		if(r[i] == 0) {
			if(ls != i && (i - ls + n) % n >= k) {
				now = i;
			}
		}
	}
	for(int i = n; i >= 1; i--) {
		a[now] = i;
		int nx = -1;
		for(int j = 1; j < k; j++) {
			int id = (now - j + n) % n;
			r[id]--;
			if(r[id] == 0) nx = id; 
		}
		if(nx == -1) {
			for(int j = 1; j < k; j++) {
				if(r[(now + j) % n] == 0) {
					nx = (now + j) % n;
					break;
				}
			}
		}
		now = nx;
	}
	for(int i = 0; i < n; i++) {
		cout << a[i] << ' ';
	}
	cout << '\n';
}

int compare_plants(int x, int y) {
	if(a[x] > a[y]) return 1;
	else return -1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -