제출 #1328093

#제출 시각아이디문제언어결과실행 시간메모리
1328093hh69선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
#include "souvenirs.h"
#include <utility>
#include <vector>

using pvi = std::pair<std::vector<int>, long long>>;
using ll = long long;
std::vector<ll> fin;
std::vector<ll> counts;

void add(pvi list){
	for(auto val: list.first)
		++counts[val];
}

void buy_souvenirs(int N, long long P0) {
	fin=std::vector<ll>(N, -1);
	counts.resize(N);
	std::stack<pvi> st;
	st.push(transaction(P0-1));
	st.top().second=P0-1-st.top().second;
	add(st.top());
	while(!st.empty()){
		pvi& cur=st.top();
		while(cur.first.size()>1){
			if(fin[(cur.first)[cur.first.size()-1]]!=-1){
				cur.second-=fin[cur.first[cur.first.size()-1]];
				cur.first.pop_back();
			}
			else break;
		}
		if(cur.first.size()==1){
			ll ind=(cur.first)[0];
			fin[ind]=cur.second;
			if(ind<N-1&&fin[ind+1]==-1){
				st.push(transaction(fin[ind]-1));
				st.top().second=fin[ind]-1-st.top().second;
				add(st.top());
			}
			else
				st.pop();
		}
		else{
			ll next_cost=cur.second/(cur.first.size());
			st.push(transaction(next_cost));
			st.top().second=next_cost-st.top().second;
			add(st.top());
		}
	}
	for(int i=0; i < N; ++i){
		while(counts[i]<i)
			transaction(fin[i]);
	}
	return;
}

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

souvenirs.cpp:5:50: error: expected ';' before '>' token
    5 | using pvi = std::pair<std::vector<int>, long long>>;
      |                                                  ^~
      |                                                  ;
souvenirs.cpp:10:6: error: variable or field 'add' declared void
   10 | void add(pvi list){
      |      ^~~
souvenirs.cpp:10:10: error: 'pvi' was not declared in this scope
   10 | void add(pvi list){
      |          ^~~
souvenirs.cpp: In function 'void buy_souvenirs(int, long long int)':
souvenirs.cpp:18:14: error: 'stack' is not a member of 'std'
   18 |         std::stack<pvi> st;
      |              ^~~~~
souvenirs.cpp:2:1: note: 'std::stack' is defined in header '<stack>'; did you forget to '#include <stack>'?
    1 | #include "souvenirs.h"
  +++ |+#include <stack>
    2 | #include <utility>
souvenirs.cpp:18:20: error: 'pvi' was not declared in this scope
   18 |         std::stack<pvi> st;
      |                    ^~~
souvenirs.cpp:18:25: error: 'st' was not declared in this scope; did you mean 'std'?
   18 |         std::stack<pvi> st;
      |                         ^~
      |                         std
souvenirs.cpp:21:9: error: 'add' was not declared in this scope
   21 |         add(st.top());
      |         ^~~
souvenirs.cpp:23:22: error: 'cur' was not declared in this scope
   23 |                 pvi& cur=st.top();
      |                      ^~~