답안 #808571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808571 2023-08-05T07:55:41 Z drdilyor 식물 비교 (IOI20_plants) C++17
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
#include "plants.h"
using namespace std;
using ll = long long;
const int inf = 1e9;

#define debug(args...) cout << "[" << #args << "]: "; debug_out(args);
void debug_out() {
    cout << endl;
}
template<typename H, typename... T>
void debug_out(H h, T... t) {
    cout << h << ", ";
    debug_out(t...);
}

void vis() {
    int n = 7;
    int k = 4;

    vector<int> arr(n);
    iota(arr.begin(), arr.end(), 1);
    map<vector<int>, vector<int>> mp;
    do {
        vector<int> r;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = i; j < i + k; j++)
                cnt += arr[j % n] > arr[i];
            r.push_back(cnt);
        }
        mp[r] = arr;
    }while (next_permutation(arr.begin(), arr.end()));
    for (auto[r, arr] : mp) {
        for (int i : r) cout << i << ' ';
        cout << "= ";
        for (int i : arr) cout << i << ' ';
        cout << endl;
    }

	return;
}

int n;
vector<int> p;

int f(int i) {
    return i < 0 ? i + n : i >= n ? i - n : 0;
}

void init(int k, std::vector<int> r) {
    n = r.size();
    p.resize(n);
    vector<int> done(n);
    int cur = n;
    for (int i = 0; i < n; i++) {
        if (done[i]) continue;
        bool ok = r[i] == 0;
        for (int j = i - k + 1; j < i; j++) {
            if (done[f(j)]) continue;
            ok &= r[f(j)] > 0;
        }
        if (ok) {
            for (int j = i - k + 1; j < i; j++) {
                if (done[f(j)]) continue;
                r[f(j)]--;
            }

            p[i] = cur--;
            done[i] = 1;
            i = -1;
        }
    }
}


int compare_plants(int x, int y) {
	return p[x] < p[y] ? -1 : 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -