답안 #813547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
813547 2023-08-07T20:03:29 Z kostka Fountain (eJOI20_fountain) C++14
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
#include "stub.h"

using namespace std;

int encode(int a, int b, int n) {
  return a*n+b;
}

int solve(int n) {
  set <int> diagonals_from_0;
  for (int i=1; i<n-1; i++) {
    if (query(0, i)) {
      diagonals_from_0.insert(i);
    }
  }
  // If there exist a diagonal cutting the polygon exactly in half,
  // that has to be the answer, as any other diagonal will have either
  // left or right distance greater than it (because all the remaining
  // diagonals will be either in left or right side of the polygon divided
  // with this diagonal).
  if (diagonals_from_0.find(n/2) != diagonals_from_0.end()) {
    return encode(0, n/2, n);
  }
  // Otherwise, we try to find the closest points to the opposite of 0 
  // that have a diagonal going from 0 in both left 
  // and right side of this polygon.
  int left = 1, right = n-1;
  for (int i=2; i<n/2; i++) {
    if (diagonals_from_0.find(i) != diagonals_from_0.end()) left = i;
  }
  for (int i=n-2; i>=(n+1)/2; i--) {
    if (diagonals_from_0.find(i) != diagonals_from_0.end()) right = i;
  }
  // This diagonal has to exist, as we don't have diagonal conneting 0
  // and the point opposite of 0, and it is a complete triangulation.
  // Therefore it is our answer.
  return encode(left, right, n);
}

Compilation message

fountain.cpp:2:10: fatal error: stub.h: No such file or directory
    2 | #include "stub.h"
      |          ^~~~~~~~
compilation terminated.