Submission #592917

#TimeUsernameProblemLanguageResultExecution timeMemory
592917skittles1412Gondola (IOI14_gondola)C++17
20 / 100
10 ms612 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \ dbgh(__VA_ARGS__); #else #define dbg(...) #define cerr \ if (false) \ cerr #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) extern "C" int valid(int n, int arr[]) { rotate(arr, min_element(arr, arr + n), arr + n); int x = -1; for (int i = 0; i < n; i++) { if (i <= n) { int cx = arr[i] - i; if (x == -1) { x = cx; } else if (x != cx) { return false; } } } return true; } extern "C" int replacement(int n, int arr[], int out[]) { int targ[n]; int x; for (int i = 0; i < n; i++) { if (arr[i] < n) { x = arr[i] - i; } } for (int i = 0; i < n; i++) { targ[i] = (x + i + n) % n; if (!targ[i]) { targ[i] = n; } dbg(targ[i]); } map<int, int> rev; for (int i = 0; i < n; i++) { rev[arr[i]] = i; } vector<int> ans; int mind = max_element(arr, arr + n) - arr, e = arr[mind]; for (int i = n + 1; i <= e; i++) { auto it = rev.find(i); int cind; if (it == rev.end()) { cind = mind; } else { cind = it->second; } ans.push_back(targ[cind]); targ[cind] = i; } copy(begin(ans), end(ans), out); return sz(ans); } extern "C" int countReplacement(int n, int inputSeq[]) {}

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:83:57: warning: no return statement in function returning non-void [-Wreturn-type]
   83 | extern "C" int countReplacement(int n, int inputSeq[]) {}
      |                                                         ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:49:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |     int x;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...