Submission #1050200

# Submission time Handle Problem Language Result Execution time Memory
1050200 2024-08-09T07:56:47 Z mychecksedad Comparing Plants (IOI20_plants) C++17
14 / 100
4000 ms 8816 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()
const int N = 3e5;

int a[N], n;
void init(int k, std::vector<int> r) {
	n = r.size();
	for(int i = 0; i < n; ++i) a[i] = 0;
	// if(2*k > n){
		int f = n-1;
		for(int rep = 0; rep < n; ++rep){
			int mx = *max_element(all(r));
			int l = n, rr = -1;
			vector<int> L;
			for(int i = 0; i < n; ++i){
				if(r[i] == mx){
					L.pb(i);
				}
			}
			int x = L[0];
			for(int i = 0; i + 1 < L.size(); ++i){
				if(L[i] + k <= L[i + 1]){
					x = L[i + 1];
					break;
				}
			}
			a[x] = f--;
			r[x] = -n;	
			// cout << x << ' ';
			for(int i = x - 1; i > x - k; --i) r[(i+n)%n]++;
		}
	// for(int i = 0; i < n; ++i) cout << a[i] << ' ';
	// }else{

	// }
}

int compare_plants(int x, int y) {
	return a[x] < a[y] ? 1 : (a[x] > a[y] ? -1 : 0);
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:26:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    for(int i = 0; i + 1 < L.size(); ++i){
      |                   ~~~~~~^~~~~~~~~~
plants.cpp:18:8: warning: unused variable 'l' [-Wunused-variable]
   18 |    int l = n, rr = -1;
      |        ^
plants.cpp:18:15: warning: unused variable 'rr' [-Wunused-variable]
   18 |    int l = n, rr = -1;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 89 ms 3096 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 89 ms 5204 KB Output is correct
11 Correct 75 ms 4984 KB Output is correct
12 Correct 102 ms 5204 KB Output is correct
13 Correct 97 ms 5208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 89 ms 3096 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 89 ms 5204 KB Output is correct
11 Correct 75 ms 4984 KB Output is correct
12 Correct 102 ms 5204 KB Output is correct
13 Correct 97 ms 5208 KB Output is correct
14 Correct 815 ms 5512 KB Output is correct
15 Execution timed out 4040 ms 8788 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 36 ms 3072 KB Output is correct
4 Execution timed out 4026 ms 8816 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 -