제출 #1249421

#제출 시각아이디문제언어결과실행 시간메모리
1249421mondellbit선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "souvenirs.h" using namespace std; #define int long long #define INF (int)1e18 mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); int n; const int N = 105; int hidden_p[N]; int counter[N]; pair <vector <int>, int> transaction(int m){ assert(m >= hidden_p[n - 1] && m < hidden_p[0]); vector <int> bought; for (int i = 0; i < n; i++){ if (m >= hidden_p[i]){ m -= hidden_p[i]; bought.push_back(i); counter[i]++; } } return make_pair(bought, m); } void buy_souvenirs(int n, int p0){ vector<set<int>> depend(n); vector<int> sum(n); vector<int> ans(n, -1); ans[0] = p0; vector <int> counter(n, 0); while (true){ int left = 0; for (int i = 0; i < n; i++){ left += ans[i] == -1; } if (left == 0){ break; } bool have = false; for (int i = n - 1; i >= 0; i--){ if (ans[i] == -1) have = true; if (ans[i] != -1 && have){ auto [vv, ll] = transaction(ans[i] - 1); set <int> ss; for (auto x : vv) ss.insert(x), counter[x]++; int got = ans[i] - 1 - ll; for (int j = 0; j < n; j++){ if (ans[j] != -1 && ss.count(j)){ ss.erase(j); got -= ans[j]; } } depend[i + 1] = ss; sum[i + 1] = got; break; } if (depend[i].size() == 1){ ans[i] = sum[i]; depend[i].clear(); for (int j = 0; j < n; j++){ if (depend[j].count(i)){ sum[j] -= ans[i]; depend[j].erase(i); } } break; } if (depend[i].size()){ int x = sum[i] / (int)depend[i].size(); auto [vv, ll] = transaction(x); set <int> ss; for (auto x : vv) ss.insert(x), counter[x]++; int got = x - ll; for (int j = 0; j < n; j++){ if (ans[j] != -1 && ss.count(j)){ got -= ans[j]; ss.erase(j); } } assert(!ss.empty()); int k = *ss.begin(); depend[k] = ss; sum[k] = got; break; } } } for (int i = 0; i < n; i++){ while (counter[i] < i){ counter[i]++; transaction(ans[i]); } } }

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

souvenirs.cpp:14:26: error: ambiguating new declaration of 'std::pair<std::vector<long long int>, long long int> transaction(long long int)'
   14 | pair <vector <int>, int> transaction(int m){
      |                          ^~~~~~~~~~~
In file included from souvenirs.cpp:2:
souvenirs.h:6:40: note: old declaration 'std::pair<std::vector<int>, long long int> transaction(long long int)'
    6 | std::pair<std::vector<int>, long long> transaction(long long M);
      |                                        ^~~~~~~~~~~