제출 #1251054

#제출 시각아이디문제언어결과실행 시간메모리
1251054hihihahaa선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
struct Equation { vector<int> elem; long long sum; Equation(vector<int> e, long long s) : elem(e), sum(s) {} void clear(vector<long long>& P, int bottom) { while (elem.back() > bottom) { // elem[0] should not be less than bottom, so no need to check elem.empty(); sum -= P[elem.back()]; elem.pop_back(); } } }; Equation modified_transaction(long long M) { pair<vector<int>, long long> raw = transaction(M); return {raw.first, M - raw.second}; } void buy_souvenirs(int N, long long P0) { vector<long long> P(N, 0); vector<int> kpi(N); // track how many of each type has been bought for (int i = 0; i < N; i++) kpi[i] = i; stack<Equation> S; // store info int bottom = N - 1; // found P[i] forall i > bottom; S.push({{0}, P0}); // find P while (bottom) { Equation u = S.top(); u.clear(P, bottom); if (u.elem.size() == 1 && u.elem[0] == bottom) { S.pop(); P[bottom] = u.sum; bottom--; } else { long long amount = u.sum/u.elem.size() - 1; Equation next = modified_transaction(amount); for (auto i: next.elem) kpi[i]--; S.push(next); } } // clean up for (int i = 0; i < N; i++) while (kpi[i]--) transaction(P[i]); }

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

souvenirs.cpp:2:5: error: 'vector' does not name a type
    2 |     vector<int> elem; long long sum;
      |     ^~~~~~
souvenirs.cpp:4:20: error: expected ')' before '<' token
    4 |     Equation(vector<int> e, long long s) : elem(e), sum(s) {}
      |             ~      ^
      |                    )
souvenirs.cpp:6:16: error: 'vector' has not been declared
    6 |     void clear(vector<long long>& P, int bottom) {
      |                ^~~~~~
souvenirs.cpp:6:22: error: expected ',' or '...' before '<' token
    6 |     void clear(vector<long long>& P, int bottom) {
      |                      ^
souvenirs.cpp: In member function 'void Equation::clear(int)':
souvenirs.cpp:7:16: error: 'elem' was not declared in this scope
    7 |         while (elem.back() > bottom) { // elem[0] should not be less than bottom, so no need to check elem.empty();
      |                ^~~~
souvenirs.cpp:7:30: error: 'bottom' was not declared in this scope
    7 |         while (elem.back() > bottom) { // elem[0] should not be less than bottom, so no need to check elem.empty();
      |                              ^~~~~~
souvenirs.cpp:8:20: error: 'P' was not declared in this scope
    8 |             sum -= P[elem.back()];
      |                    ^
souvenirs.cpp: In function 'Equation modified_transaction(long long int)':
souvenirs.cpp:15:10: error: 'vector' was not declared in this scope
   15 |     pair<vector<int>, long long> raw = transaction(M);
      |          ^~~~~~
souvenirs.cpp:15:5: error: 'pair' was not declared in this scope
   15 |     pair<vector<int>, long long> raw = transaction(M);
      |     ^~~~
souvenirs.cpp:15:17: error: expected primary-expression before 'int'
   15 |     pair<vector<int>, long long> raw = transaction(M);
      |                 ^~~
souvenirs.cpp:16:13: error: 'raw' was not declared in this scope
   16 |     return {raw.first, M - raw.second};
      |             ^~~
souvenirs.cpp:16:38: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'Equation'
   16 |     return {raw.first, M - raw.second};
      |                                      ^
      |                                      |
      |                                      <brace-enclosed initializer list>
souvenirs.cpp: In function 'void buy_souvenirs(int, long long int)':
souvenirs.cpp:20:5: error: 'vector' was not declared in this scope
   20 |     vector<long long> P(N, 0);
      |     ^~~~~~
souvenirs.cpp:20:12: error: expected primary-expression before 'long'
   20 |     vector<long long> P(N, 0);
      |            ^~~~
souvenirs.cpp:21:12: error: expected primary-expression before 'int'
   21 |     vector<int> kpi(N); // track how many of each type has been bought
      |            ^~~
souvenirs.cpp:22:33: error: 'kpi' was not declared in this scope
   22 |     for (int i = 0; i < N; i++) kpi[i] = i;
      |                                 ^~~
souvenirs.cpp:23:5: error: 'stack' was not declared in this scope
   23 |     stack<Equation> S; // store info
      |     ^~~~~
souvenirs.cpp:23:19: error: expected primary-expression before '>' token
   23 |     stack<Equation> S; // store info
      |                   ^
souvenirs.cpp:23:21: error: 'S' was not declared in this scope
   23 |     stack<Equation> S; // store info
      |                     ^
souvenirs.cpp:29:17: error: 'P' was not declared in this scope
   29 |         u.clear(P, bottom);
      |                 ^
souvenirs.cpp:30:15: error: 'struct Equation' has no member named 'elem'
   30 |         if (u.elem.size() == 1 && u.elem[0] == bottom) {
      |               ^~~~
souvenirs.cpp:30:37: error: 'struct Equation' has no member named 'elem'
   30 |         if (u.elem.size() == 1 && u.elem[0] == bottom) {
      |                                     ^~~~
souvenirs.cpp:35:40: error: 'struct Equation' has no member named 'elem'
   35 |             long long amount = u.sum/u.elem.size() - 1;
      |                                        ^~~~
souvenirs.cpp:37:31: error: 'struct Equation' has no member named 'elem'
   37 |             for (auto i: next.elem) kpi[i]--;
      |                               ^~~~
souvenirs.cpp:37:37: error: 'kpi' was not declared in this scope
   37 |             for (auto i: next.elem) kpi[i]--;
      |                                     ^~~
souvenirs.cpp:42:40: error: 'kpi' was not declared in this scope
   42 |     for (int i = 0; i < N; i++) while (kpi[i]--) transaction(P[i]);
      |                                        ^~~
souvenirs.cpp:42:62: error: 'P' was not declared in this scope
   42 |     for (int i = 0; i < N; i++) while (kpi[i]--) transaction(P[i]);
      |                                                              ^
souvenirs.cpp:42:50: error: 'transaction' was not declared in this scope
   42 |     for (int i = 0; i < N; i++) while (kpi[i]--) transaction(P[i]);
      |                                                  ^~~~~~~~~~~