Submission #832679

# Submission time Handle Problem Language Result Execution time Memory
832679 2023-08-21T13:38:46 Z Theo830 Comparing Plants (IOI20_plants) C++17
14 / 100
4000 ms 7404 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define f(i,a,b) for(ll i = a;i < b;i++)
ll arr[200005];
const ll INF = 1e9;
void init(int k,vector<int>r){
    ll n = r.size();
    ll cur = n;
    while(1){
        vector<ll>possible;
        f(i,0,n){
            if(r[i] == 0){
                possible.pb(i);
            }
        }
        if(possible.empty()){
            break;
        }
        ll siz = possible.size();
        bool ok[siz];
        vector<ll>kame;
        f(i,0,siz){
            ll dist = possible[(i+1)%siz] - possible[i];
            if(dist <= 0){
                dist += n;
            }
            if(dist >= k){
                kame.pb(possible[(i+1)%siz]);
            }
        }
        for(auto x:kame){
            arr[x] = cur;
            r[x] = INF;
            ll s = k;
            ll pos = x;
            while(s--){
                r[pos]--;
                pos--;
                if(pos < 0){
                    pos += n;
                }
            }
        }
        cur--;
    }
	return;
}
int compare_plants(int x, int y) {
	if(arr[x] == arr[y]){
        return 0;
	}
	if(arr[x] > arr[y]){
        return 1;
	}
	return -1;
}
/*
static int n, k, q;
static std::vector<int> r;
static std:: vector<int> x;
static std:: vector<int> y;
static std:: vector<int> answer;
int main() {
	assert(scanf("%d%d%d", &n, &k, &q) == 3);
	r.resize(n);
	answer.resize(q);
	for (int i = 0; i < n; i++) {
		int value;
		assert(scanf("%d", &value) == 1);
		r[i] = value;
	}
	x.resize(q);
	y.resize(q);
	for (int i = 0; i < q; i++) {
		assert(scanf("%d%d", &x[i], &y[i]) == 2);
	}
	fclose(stdin);
	init(k, r);
	for (int i = 0; i < q; i++) {
		answer[i] = compare_plants(x[i], y[i]);
	}

	for (int i = 0; i < q; i++) {
		printf("%d\n", answer[i]);
	}

	fclose(stdout);

	return 0;
}
*/

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:26:14: warning: unused variable 'ok' [-Wunused-variable]
   26 |         bool ok[siz];
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 94 ms 3212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 73 ms 3128 KB Output is correct
11 Correct 114 ms 3152 KB Output is correct
12 Correct 64 ms 3248 KB Output is correct
13 Correct 80 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 94 ms 3212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 73 ms 3128 KB Output is correct
11 Correct 114 ms 3152 KB Output is correct
12 Correct 64 ms 3248 KB Output is correct
13 Correct 80 ms 3204 KB Output is correct
14 Correct 491 ms 3388 KB Output is correct
15 Execution timed out 4059 ms 5848 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 43 ms 4884 KB Output is correct
4 Execution timed out 4045 ms 7404 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -