제출 #1312084

#제출 시각아이디문제언어결과실행 시간메모리
1312084pedreitorzeldaSouvenirs (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long /* vector<int>a; pair<vector<int>,int>transaction(int num){ vector<int>ans; for(int i=0;i<a.size();i++){ if(num>=a[i]){ ans.push_back(i); num-=a[i]; } }return {ans,num}; }*/ void to_buy(int ind,int cost,vector<int>&vals,vector<int>&cant){ pair<vector<int>,int>ans = transaction(cost); for(auto it : ans.first)cant[it]++; if(ans.first.size()==1){ vals[ind]=cost-ans.second; }else{ reverse(ans.first.begin(),ans.first.end()); int nxt = 0; for(auto it : ans.first){ if(vals[it]==-1)to_buy(it,(cost+ans.first.size()-1)/ans.first.size(),vals,cant); nxt+=vals[it]; }vals[ind]=cost-nxt; }return; } void buy_souvenirs(int N, int P0){ vector<int>vals(N,-1); vector<int>cant(N,0); vals[0]=P0; for(int i=1;i<N;i++){ if(vals[i]==-1){ pair<vector<int>,int>ans = transaction(vals[i-1]-1); for(auto it : ans.first)cant[it]++; if(ans.first.size()==1){ vals[i] = vals[i-1]-1-ans.second; }else{reverse(ans.first.begin(),ans.first.end()); for(auto it : ans.first){ if(vals[it]==-1)to_buy(it,(vals[i-1]-1+ans.first.size()-1)/ans.first.size(),vals,cant); } } } } for(int i=0;i<N;i++){ if(cant[i]>i)cout << "BBBBAAAAAAAAD\n"; else{ while(cant[i]<i){ transaction(vals[i]); cant[i]++; } } }return; } /* signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; const int MAXI = 100000; while(t--){ int n = rand()%100; a.resize(n); for(int i=0;i<n;i++){ a[i] = rand()%MAXI; } sort(a.begin(),a.end()); auto it = unique(a.begin(),a.end()); int x = 0; while(it!=a.end()){ (*it) = MAXI+x; x++; it++; } sort(a.begin(),a.end()); buy_souvenirs(n,a[0]); a.clear(); } return 0; }*/

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

souvenirs.cpp: In function 'void to_buy(long long int, long long int, std::vector<long long int>&, std::vector<long long int>&)':
souvenirs.cpp:16:32: error: 'transaction' was not declared in this scope
   16 |     pair<vector<int>,int>ans = transaction(cost);
      |                                ^~~~~~~~~~~
souvenirs.cpp: In function 'void buy_souvenirs(long long int, long long int)':
souvenirs.cpp:36:40: error: 'transaction' was not declared in this scope
   36 |             pair<vector<int>,int>ans = transaction(vals[i-1]-1);
      |                                        ^~~~~~~~~~~
souvenirs.cpp:51:17: error: 'transaction' was not declared in this scope
   51 |                 transaction(vals[i]);
      |                 ^~~~~~~~~~~