제출 #1260991

#제출 시각아이디문제언어결과실행 시간메모리
1260991robijoy선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
/*
 *   Starting with the name of almighty ALLAH
 */
// #include "souvenirs.h"
#include <bits/stdc++.h>

using namespace std;


int N = 6;
vector<long long> P = {30, 29, 28, 27, 26, 24};
vector<int> Q(N);

pair<vector<int>, long long> transaction(long long M) {
  vector<int> L;
  long long R = M;
  for (int i = 0; i < N; i++) {
    if (R >= P[i]) {
      R -= P[i];
      Q[i]++;
      L.push_back(i);
    }
  }
  return {L, R};
}

void buy_souvenirs(int N, long long P0) {
    vector<int> left(N),P(N);
    for(int i = 0; i < N; ++i) left[i] = i;

    P[0] = P0;
    
    for (int i = 1; i < N; ++i)
    {
        pair<vector<int>,long long> res = transaction(P[i-1]-1);
        if(res.first.size() == 1) {
            int ret = res.second;
            P[i] = (P[i-1] - 1 - ret);
            left[i]--;
        } else {
            int ret = res.second;
            P[i] = (P[i-1] - 1 - ret);
            left[N-1]--;
            left[P[i]]--;
            P[N-1] = 1;
        }
    }
    for (int i = 0; i < left.size(); ++i)
    {
        int x = left[i];
        for (int j = 0; j < x; ++j)
        {
            transaction(P[i]);
        }
    }
}

int main() {
    buy_souvenirs(6,30);
}

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

/usr/bin/ld: /tmp/cckWsEIp.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmticwV.o:souvenirs.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cckWsEIp.o: in function `transaction(long long)':
stub.cpp:(.text+0x1d0): multiple definition of `transaction(long long)'; /tmp/ccmticwV.o:souvenirs.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status