제출 #1290815

#제출 시각아이디문제언어결과실행 시간메모리
1290815ecen30선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
//testing AI code #include <vector> using namespace std; // Provided by the judge: extern std::pair<std::vector<int>, long long> transaction(long long M); void buy_souvenirs(int N, long long P0) { std::vector<long long> prices(N, -1); prices[0] = P0; // Step 1: Discover unknown prices. // For M = 1 to P0 - 1, run transaction and map which souvenir you get for each M. int found = 1; for (long long m = 1; m < P0; ++m) { auto res = transaction(m); for(int type : res.first) { if(type != 0 && prices[type] == -1) { prices[type] = m; ++found; } } if(found == N) break; // All found } // Step 2: For each souvenir type i=1..N-1, buy exactly i of type i. std::vector<int> Q(N, 0); for(int i = 1; i < N; ++i) { for(int k = 0; k < i; ++k) { auto res = transaction(prices[i]); for(int t : res.first) { if(t==i) ++Q[i]; } } } // Output results for grader for(int i=0; i<N; ++i) { printf("%d%c", Q[i], " \n"[i+1==N]); } }

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

souvenirs.cpp: In function 'void buy_souvenirs(int, long long int)':
souvenirs.cpp:39:9: error: 'printf' was not declared in this scope
   39 |         printf("%d%c", Q[i], " \n"[i+1==N]);
      |         ^~~~~~
souvenirs.cpp:3:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
    2 | #include <vector>
  +++ |+#include <cstdio>
    3 | using namespace std;