제출 #304607

#제출 시각아이디문제언어결과실행 시간메모리
304607SorahISA식물 비교 (IOI20_plants)C++17
14 / 100
4091 ms6084 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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) {
      |                         ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...