제출 #1347433

#제출 시각아이디문제언어결과실행 시간메모리
1347433nadavisraeliHack (APIO25_hack)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int hack() {
    int m = 1;
    while (1) {
        vector<long long> vec;
        for (int i = 0; i < m; i++) vec.push_back(i);
        for (int i = 1; i <= m; i++) vec.push_back(i * m);
        if (collisions(vec)) break;
        m *= 2;
    }

    if (m == 1) return 1;

    int l = 1, h = m;
    while (l < h) {
        int mid = (l + h) / 2;
        vector<long long> vec;
        for (int i = 0; i < m; i++) vec.push_back(i);
        for (int i = l; i <= mid; i++) {
            vec.push_back(i * m);
        }
        if (collisions(vec)) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }

    int q = l;

    l = 0, h = m - 1;
    while (l < h) {
        int mid = (l + h) / 2;
        vector<long long> vec = {q * m};
        for (int i = l; i <= mid; i++) {
            vec.push_back(i);
        }
        if (collisions(vec)) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }

    return q * m - l;
}

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

hack.cpp: In function 'int hack()':
hack.cpp:10:13: error: 'collisions' was not declared in this scope
   10 |         if (collisions(vec)) break;
      |             ^~~~~~~~~~
hack.cpp:24:13: error: 'collisions' was not declared in this scope
   24 |         if (collisions(vec)) {
      |             ^~~~~~~~~~
hack.cpp:40:13: error: 'collisions' was not declared in this scope
   40 |         if (collisions(vec)) {
      |             ^~~~~~~~~~