답안 #304585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304585 2020-09-21T14:33:38 Z SorahISA 식물 비교 (IOI20_plants) C++17
0 / 100
1 ms 256 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

int n;
vector<pii> ans;

void init(int k, vector<int> r) {
    n = r.size();
    
    int ltok = 0, rtok = 0;
    for (int i = 0; i < n; ++i) {
        if (r[(i-1+n)%n] == 0) ltok = i;
        if (i > rtok) ltok = rtok = i;
        while (r[rtok]         == 0) rtok = (rtok + 1) % n;
        while (r[(ltok-1+n)%n] == 1) ltok = (ltok - 1 + n) % n;
        ans.eb(ltok, rtok < ltok ? rtok + n : rtok);
        // cout << ltok << " " << rtok << "\n";
    }
    
    /*
    cout << "ans test\n";
    for (auto [x, y] : ans) {
        cout << " -> " << x << " " << y << "\n";
    }
    */
    
    return;
}

int compare_plants(int x, int y) {
    if (ans[x].X <= y   and y   <= ans[x].Y) return 1;
    if (ans[x].X <= y+n and y+n <= ans[x].Y) return 1;
    if (ans[y].X <= x   and x   <= ans[y].Y) return -1;
    if (ans[y].X <= x+n and x+n <= ans[y].Y) return -1;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -