답안 #808566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808566 2023-08-05T07:54:04 Z drdilyor 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
#define _GLIBCXX_DEBUG
#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;
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++) {
            int jj = (j+n) % n;
            if (done[jj]) continue;
            ok &= r[jj] > 0;
        }
        if (ok) {
            for (int j = i - k + 1; j < i; j++) {
                int jj = (j+n) % n;
                if( done[jj]) continue;
                r[(j + n) % n]--;
            }

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


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

Compilation message

/usr/bin/ld: /tmp/ccAvtGHh.o: in function `main':
grader.cpp:(.text.startup+0x2f6): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status