제출 #1252835

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

void buy_souvenirs(int N, long long P0) {
	// std::pair<std::vector<int>, long long> res = transaction(3);
	std::pair<std::vector<int>, long long> res;
	if (N == 2) {
		res = transaction(P0 - 1);
		return;
	}
	std::vector<int> p(N, 0);
	std::vector<int> cnt(N, 0);
	p[0] = P0;
	int call = 0;
	for (int i = 1; i < N; i++) {
		++call;
		assert(call <= 5000);
		res = transaction(p[i - 1] - 1);
		cnt[i]++;
		p[i] = p[i - 1] - 1;
		if ((int) res.first.size() > 1 || res.second > 0) p[i]--;
		if ((int) res.first.size() > 1) cnt[res.first[1]]++;
		while (cnt[i] < i) {
			++call;
			assert(call <= 5000);
			res = transaction(p[i]);
			++cnt[i];
		}
	}
	return;
}

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

souvenirs.cpp: In function 'void buy_souvenirs(int, long long int)':
souvenirs.cpp:18:17: error: 'assert' was not declared in this scope
   18 |                 assert(call <= 5000);
      |                 ^~~~~~
souvenirs.cpp:2:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    1 | #include "souvenirs.h"
  +++ |+#include <cassert>
    2 | #include <utility>