제출 #1346876

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

using l = long long;

const int S = 26767;
const int M = 1e9;

#define cl collisions

vector<int> f(int x){
    vector<int> r;
    for(int i=2;i*i<=x;i++){
        while(x%i==0){
            r.push_back(i);
            x/=i;
        }
    }
    if(x>1) r.push_back(x);
    return r;
}

int hack(){
    vector<l> a,b;

    for(int i=1;i<=S;i++) a.push_back(i);
    for(int i=S*(M/2/S);i<=M+S;i+=S) b.push_back(i);

    while(a.size()>1||b.size()>1){
        if(a.size()>b.size()){
            int n=a.size();
            vector<l> x(a.begin(),a.begin()+n/2),y(a.begin()+n/2,a.end());

            vector<l> t=y;
            t.insert(t.end(),b.begin(),b.end());
            if(cl(t)) a=y;
            else a=x;
        }else{
            int n=b.size();
            vector<l> x(b.begin(),b.begin()+n/2),y(b.begin()+n/2,b.end());

            vector<l> t=a;
            t.insert(t.end(),x.begin(),x.end());
            if(cl(t)) b=x;
            else b=y;
        }
    }

    int u=a[0],v=b[0];
    int d=v-u;

    for(int p:f(d)){
        d/=p;
        if(cl({1,(l)d+1})==0) d*=p;
    }

    return d;
}

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

hack.cpp: In function 'int hack()':
hack.cpp:9:12: error: 'collisions' was not declared in this scope
    9 | #define cl collisions
      |            ^~~~~~~~~~
hack.cpp:36:16: note: in expansion of macro 'cl'
   36 |             if(cl(t)) a=y;
      |                ^~
hack.cpp:9:12: error: 'collisions' was not declared in this scope
    9 | #define cl collisions
      |            ^~~~~~~~~~
hack.cpp:44:16: note: in expansion of macro 'cl'
   44 |             if(cl(t)) b=x;
      |                ^~
hack.cpp:9:12: error: 'collisions' was not declared in this scope
    9 | #define cl collisions
      |            ^~~~~~~~~~
hack.cpp:54:12: note: in expansion of macro 'cl'
   54 |         if(cl({1,(l)d+1})==0) d*=p;
      |            ^~