Submission #637290

#TimeUsernameProblemLanguageResultExecution timeMemory
637290ghostwriterGondola (IOI14_gondola)C++14
55 / 100
18 ms2364 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #include "grader.cpp" #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int MAXA = 25e4 + 1; bool checkdistinct(int n, int inputSeq[]) { vi c(MAXA, 0); FOR(i, 0, n - 1) { ++c[inputSeq[i]]; if (c[inputSeq[i]] > 1) return 0; } return 1; } int getoriginalpos(int n, int inputSeq[]) { FOR(i, 0, n - 1) if (inputSeq[i] <= n) return i; return -1; } int valid(int n, int inputSeq[]) { if (!checkdistinct(n, inputSeq)) return 0; int pos = getoriginalpos(n, inputSeq); if (pos == -1) return 1; FOR(i, 0, n - 1) { if (inputSeq[i] > n || i == pos) continue; int val = (i - pos + inputSeq[pos] - 1 + n) % n + 1; if (inputSeq[i] != val) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vpi a; int pos = getoriginalpos(n, gondolaSeq); if (pos == -1) pos = 0; FOR(i, 0, n - 1) { if (gondolaSeq[i] <= n) continue; int val = (i - pos + gondolaSeq[pos] - 1 + n) % n + 1; a.pb({gondolaSeq[i], val}); } sort(all(a)); int cur = n, l = 0; EACH(i, a) { replacementSeq[l++] = i.nd; ++cur; WHILE(cur < i.st) replacementSeq[l++] = cur++; } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; } /* 4 6 8 7 10 6 1 2 */

Compilation message (stderr)

gondola.cpp: In function 'bool checkdistinct(int, int*)':
gondola.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
gondola.cpp:41:5: note: in expansion of macro 'FOR'
   41 |     FOR(i, 0, n - 1) {
      |     ^~~
gondola.cpp: In function 'int getoriginalpos(int, int*)':
gondola.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
gondola.cpp:48:5: note: in expansion of macro 'FOR'
   48 |     FOR(i, 0, n - 1)
      |     ^~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
gondola.cpp:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 0, n - 1) {
      |     ^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
gondola.cpp:71:5: note: in expansion of macro 'FOR'
   71 |     FOR(i, 0, n - 1) {
      |     ^~~
gondola.cpp:28:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   28 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
gondola.cpp:78:5: note: in expansion of macro 'EACH'
   78 |     EACH(i, a) {
      |     ^~~~
#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...