Submission #790188

#TimeUsernameProblemLanguageResultExecution timeMemory
790188Sohsoh84Gondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define sep ' ' #define debug(x) cerr << #x << ": " << x << endl; const int MAXN = 1e6 + 10; int A[MAXN]; int valid(int n, int inputSeq[]) { int s = -1; set<int> tst; for (int i = 0; i < n; i++) inputSeq[i]--; for (int i = 0; i < n; i++) { if (inputSeq[i] < n) s = i; tst.insert(inputSeq[i]); } if (int(tst.size()) < n) return 0; if (s == -1) return 1; int shift_val = (s - inputSeq[s] + n) % n; for (int j = 0; j < n; j++) A[j] = inputSeq[(j + shift_val) % n]; set<int> st; for (int i = 0; i < n; i++) { if (A[i] < n) if (A[i] != i) return 0; else A[i] = i; st.insert(A[i]); } return st.size() == n; } //---------------------- int replacement(int n, int gondolaSeq[], int res[]) { for (int i = 0; i < n; i++) inputSeq[i]--; for (int i = 0; i < n; i++) { if (inputSeq[i] < n) s = i; } int shift_val = (s == -1 ? 0 : (s - inputSeq[s] + n) % n); for (int j = 0; j < n; j++) A[j] = inputSeq[(j + shift_val) % n]; set<int> st; int mx = *max_element(A, A + n); for (int i = 0; i <= mx; i++) st.insert(i); for (int i = 0; i < n; i++) st.erase(A[i]); set<pll> gond; for (int i = 0; i < n; i++) gond.insert({A[i], i}); int m = 0; while (gond.rbegin() -> X > n) { auto [x, ind] = *prev(gond.end()); gond.erase(prev(gond.end())); if (st.find(x - 1) != st.end()) { A[ind] = x - 1; st.erase(x - 1); res[m++] = x - 1; } else { A[ind] = ind; st.erase(ind); res[m++] = ind; } gond.insert(A[ind, ind]); } reverse(res, res + m); return m; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:33:6: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   33 |   if (A[i] < n)
      |      ^
gondola.cpp:40:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |  return st.size() == n;
      |         ~~~~~~~~~~^~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:46:30: error: 'inputSeq' was not declared in this scope
   46 |  for (int i = 0; i < n; i++) inputSeq[i]--;
      |                              ^~~~~~~~
gondola.cpp:48:7: error: 'inputSeq' was not declared in this scope
   48 |   if (inputSeq[i] < n)
      |       ^~~~~~~~
gondola.cpp:49:4: error: 's' was not declared in this scope
   49 |    s = i;
      |    ^
gondola.cpp:52:19: error: 's' was not declared in this scope
   52 |  int shift_val = (s == -1 ? 0 : (s - inputSeq[s] + n) % n);
      |                   ^
gondola.cpp:52:38: error: 'inputSeq' was not declared in this scope
   52 |  int shift_val = (s == -1 ? 0 : (s - inputSeq[s] + n) % n);
      |                                      ^~~~~~~~
gondola.cpp:64:6: error: 'pll' was not declared in this scope
   64 |  set<pll> gond;
      |      ^~~
gondola.cpp:64:9: error: template argument 1 is invalid
   64 |  set<pll> gond;
      |         ^
gondola.cpp:64:9: error: template argument 2 is invalid
gondola.cpp:64:9: error: template argument 3 is invalid
gondola.cpp:66:8: error: request for member 'insert' in 'gond', which is of non-class type 'int'
   66 |   gond.insert({A[i], i});
      |        ^~~~~~
gondola.cpp:69:14: error: request for member 'rbegin' in 'gond', which is of non-class type 'int'
   69 |  while (gond.rbegin() -> X > n) {
      |              ^~~~~~
gondola.cpp:70:30: error: request for member 'end' in 'gond', which is of non-class type 'int'
   70 |   auto [x, ind] = *prev(gond.end());
      |                              ^~~
gondola.cpp:71:8: error: request for member 'erase' in 'gond', which is of non-class type 'int'
   71 |   gond.erase(prev(gond.end()));
      |        ^~~~~
gondola.cpp:71:24: error: request for member 'end' in 'gond', which is of non-class type 'int'
   71 |   gond.erase(prev(gond.end()));
      |                        ^~~
gondola.cpp:82:8: error: request for member 'insert' in 'gond', which is of non-class type 'int'
   82 |   gond.insert(A[ind, ind]);
      |        ^~~~~~