답안 #808602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808602 2023-08-05T08:08:23 Z drdilyor 식물 비교 (IOI20_plants) C++17
14 / 100
4000 ms 7204 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 : i;
}

void init(int k, std::vector<int> r) {
    n = r.size();
    p.resize(n);
    vector<int> done(n);

    for (int step = 0; step < n; step++) {
        vector<int> bad(n);
        int p0 = -1;
        for (int i = 0; i < n; i++)
            if (!done[i] && r[i] == 0) p0 = i;
        p0 -= n;
        int found = -1;
        for (int i = 0; i < n; i++) {
            if (done[i]) continue;
            if (r[i] == 0 && p0 <= i - k) {
                found = i;
                break;
            }
            if (r[i] == 0) p0 = i;
        }

        p[found] = n - step;
        done[found] = 1;
        for (int j = 1; j < k; j++)
            r[f(found - j)]--;
    }
}


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 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 129 ms 3188 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 5 ms 312 KB Output is correct
10 Correct 130 ms 3916 KB Output is correct
11 Correct 81 ms 3760 KB Output is correct
12 Correct 84 ms 3940 KB Output is correct
13 Correct 133 ms 3760 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 129 ms 3188 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 5 ms 312 KB Output is correct
10 Correct 130 ms 3916 KB Output is correct
11 Correct 81 ms 3760 KB Output is correct
12 Correct 84 ms 3940 KB Output is correct
13 Correct 133 ms 3760 KB Output is correct
14 Correct 1800 ms 4032 KB Output is correct
15 Execution timed out 4078 ms 7204 KB Time limit exceeded
16 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 Correct 49 ms 3044 KB Output is correct
4 Execution timed out 4082 ms 6476 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 -