Submission #832674

# Submission time Handle Problem Language Result Execution time Memory
832674 2023-08-21T13:36:38 Z Theo830 Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 312 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]);
            }
        }
        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;
}

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 308 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 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 308 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -