Submission #302037

# Submission time Handle Problem Language Result Execution time Memory
302037 2020-09-18T11:33:54 Z VEGAnn Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 416 KB
#include "plants.h"
#include <bits/stdc++.h>
#define PB push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
const int N = 200100;
const int oo = 2e9;
vector<int> vc, perm;
int per[N];

void init(int k, vector<int> r) {
    int n = sz(r);

    assert(2 * k > n);

    k = 4; n = 5;

    perm.clear();

    perm.resize(n);

    for (int i = 0; i < n; i++)
        perm[i] = i;

    r.resize(n);

    do {
        for (int i = 0; i < n; i++){
            r[i] = 0;

            for (int it = 1, j = i; it < k; it++){
                j = (j + 1) % n;

                r[i] += bool(perm[j] > perm[i]);
            }
        }

        for (int it = n - 1; it >= 0; it--){
            vc.clear();

            for (int i = 0; i < n; i++)
                if (r[i] == 0)
                    vc.PB(i);

            if (sz(vc) == 0){
                for (int i = 0; i < n; i++)
                    cerr << perm[i] << " ";
                return;
            }

            int cand = -1, cnt = 0;

            for (int it = 0; it < sz(vc); it++){
                int cur = vc[it];
                int pre = vc[(it + sz(vc) - 1) % sz(vc)];

                if (pre < cur){
                    if (cur - pre + n < k){
                        cand = cur;
                        cnt++;
                    }
                } else {
                    if (cur - pre < k){
                        cand = cur;
                        cnt++;
                    }
                }
            }

            per[cand] = it;
            r[cand] = oo;

            for (int i = 1, loc = cand; i < k; i++){
                loc = (loc + n - 1) % n;

                r[loc]--;
            }
    }

    } while (next_permutation(all(perm)));

    return;
}

int compare_plants(int x, int y) {
    return (per[x] > per[y] ? 1 : -1);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -