답안 #659866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659866 2022-11-19T14:35:06 Z evenvalue 식물 비교 (IOI20_plants) C++17
5 / 100
101 ms 9488 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;

using int64 = long long;
using ld = long double;

constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;

vector<int> psum;
int n = -1;

void init(int k, vector<int> r) {
  assert(k == 2);
  n = r.size();

  r.insert(r.end(), r.begin(), r.end());
  psum.resize(2 * n + 1, 0);

  for (int i = 0; i < 2 * n; i++) {
    psum[i + 1] = psum[i] + r[i];
  }
}

int compare_plants(int x, int y) {
  if (x > y) swap(x, y);
  auto get = [&](const int l, const int r) {
    return psum[r + 1] - psum[l];
  };

  const int dist1 = y - x;
  const int dist2 = x + n - y;

  if (get(x, y - 1) == 0 or get(y, n + x - 1) == dist2) {
    return 1;
  } else if (get(x, y - 1) == dist1 or get(y, n + x - 1) == 0) {
    return -1;
  } else {
    return 0;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 50 ms 4080 KB Output is correct
7 Correct 68 ms 5624 KB Output is correct
8 Correct 101 ms 9408 KB Output is correct
9 Correct 71 ms 9420 KB Output is correct
10 Correct 82 ms 9368 KB Output is correct
11 Correct 76 ms 9420 KB Output is correct
12 Correct 72 ms 9416 KB Output is correct
13 Correct 66 ms 9404 KB Output is correct
14 Correct 93 ms 9488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Runtime error 1 ms 432 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Runtime error 1 ms 432 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Runtime error 1 ms 428 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 50 ms 4080 KB Output is correct
7 Correct 68 ms 5624 KB Output is correct
8 Correct 101 ms 9408 KB Output is correct
9 Correct 71 ms 9420 KB Output is correct
10 Correct 82 ms 9368 KB Output is correct
11 Correct 76 ms 9420 KB Output is correct
12 Correct 72 ms 9416 KB Output is correct
13 Correct 66 ms 9404 KB Output is correct
14 Correct 93 ms 9488 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 304 KB Output is correct
17 Runtime error 1 ms 432 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -