답안 #321773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321773 2020-11-13T10:53:44 Z grt 식물 비교 (IOI20_plants) C++17
14 / 100
166 ms 11756 KB
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;

#define ST first
#define ND second
#define PB push_back

const int nax = 5000 + 10, INF = 1e9 + 10;
int n, k;
int val[nax];
int num[nax];

void upd(int a, int b, int x) {
    for(int i = a; i <= b; ++i) val[i] += x;
}

int qr() {
    vi zero = {};
    for(int i = 0; i < n; ++i) if(val[i] == 0) zero.PB(i);
    if((int)zero.size() == 1) return zero[0];
    for(int i = 1; i < (int)zero.size(); ++i) {
        if(zero[i] - zero[i - 1] >= k) {
            return zero[i];
        }
    }
    return zero[0];
}

void init(int K, vi r) {
    k = K;
    n = (int)r.size();
    for(int i = 0; i < n; ++i) val[i] = r[i];
    int cur = n;
    for(int step = 0; step < n; ++step) {
        int x = qr();
        upd(x, x, INF);
        num[x] = cur--;
        upd(max(0, x - k + 1),x-1, -1);
        upd(x - k + 1 + n, n - 1, -1);
    }
}

int compare_plants(int x, int y) {
    if(num[x] < num[y]) return -1;
    else return 1;
}

//int main() {
//    init(3, {0, 1, 1, 2});
//    cout << compare_plants(0, 2) << "\n";
//    cout << compare_plants(1, 2) << "\n";
//}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 159 ms 5228 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 157 ms 5168 KB Output is correct
11 Correct 166 ms 5100 KB Output is correct
12 Correct 152 ms 5248 KB Output is correct
13 Correct 156 ms 5100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 159 ms 5228 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 157 ms 5168 KB Output is correct
11 Correct 166 ms 5100 KB Output is correct
12 Correct 152 ms 5248 KB Output is correct
13 Correct 156 ms 5100 KB Output is correct
14 Runtime error 52 ms 7916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 82 ms 4972 KB Output is correct
4 Runtime error 78 ms 11756 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -