답안 #304607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304607 2020-09-21T15:15:34 Z SorahISA 식물 비교 (IOI20_plants) C++17
14 / 100
4000 ms 6084 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define debugV(x) cout << #x << " : "; for (auto _ : x) cout << _ << " "; cout << "\n";

int n;
vector<int> val;

void init(int k, vector<int> r) {
    n = r.size(), val.assign(n, 0);
    
    for (int i = n; i >= 1; --i) {
        vector<int> check;
        for (int j = 0; j < n; ++j) {
            if (r[j] == 0 and val[j] == 0) check.eb(j);
        }
        
        // debugV(check);
        
        int ans = check[0];
        for (int j = 0; j < check.size()-1; ++j) {
            if (check[j] + k - 1 < check[j+1]) ans = check[j+1];
        }
        val[ans] = i;
        for (int j = 1; j < k; ++j) --r[(ans-j+n)%n];
    }
    
    // debugV(val);
    
    return;
}

int compare_plants(int x, int y) {
    if (val[x] != val[y]) return val[x] > val[y] ? 1 : -1;
    return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j = 0; j < check.size()-1; ++j) {
      |                         ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 298 ms 3328 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 12 ms 384 KB Output is correct
10 Correct 302 ms 3192 KB Output is correct
11 Correct 259 ms 3260 KB Output is correct
12 Correct 244 ms 3320 KB Output is correct
13 Correct 340 ms 3296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 298 ms 3328 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 12 ms 384 KB Output is correct
10 Correct 302 ms 3192 KB Output is correct
11 Correct 259 ms 3260 KB Output is correct
12 Correct 244 ms 3320 KB Output is correct
13 Correct 340 ms 3296 KB Output is correct
14 Correct 2918 ms 3448 KB Output is correct
15 Execution timed out 4091 ms 4984 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 90 ms 3192 KB Output is correct
4 Execution timed out 4088 ms 6084 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -