Submission #582582

#TimeUsernameProblemLanguageResultExecution timeMemory
582582drdilyorGondola (IOI14_gondola)C++17
20 / 100
45 ms5068 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #ifdef ONPC #define cerr cout #include "t_debug.cpp" #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define sz(a) ((int) (a).size()) #define cut(s) {cout << s << '\n'; return 0;} #include "gondola.h" using namespace std; using ll = long long; using vi = vector<int>; namespace pd = __gnu_pbds; template<typename K> using ordered_set = pd::tree<K, pd::null_type, less<K>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>; template<typename... T> using hash_table = pd::gp_hash_table<T...>; const int INF = 1e9; const ll INFL = 1e18; const int N = 250000; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); int valid(int n, int* a_) { vi a(n); for (int i = 0; i < n; i++) a[i] = a_[i]; set<int> visited; for (int i = 0; i < n; i++) { if (visited.count(a[i])) return 0; visited.insert(a[i]); } int start = -1; for (int i = 0; i < n; i++) { if (a[i] <= n) { start = i - a[i] + 1; if (start < 0) start += n; break; } } if (start == -1) return 0; rotate(a.begin(), a.begin()+start, a.end()); for (int i = 0; i < n; i++) { if (a[i] <= n && a[i] != i+1) return 0; } return 1; } int replacement(int n, int a_[], int b[]) { vi a(n), orig(n); for (int i = 0; i < n; i++) a[i] = a_[i], orig[i] = i+1; int mx = 0, mxi = -1; for (int i = 0; i < n; i++) { if (a[i] > mx) mx =a[i], mxi = i; } int start = 0; for (int i = 0; i < n; i++) { if (a[i] <= n) { start = i - a[i] + 1; if (start < 0) start += n; break; } } rotate(orig.begin(), orig.begin()+start, orig.end()); debug(a, orig); vi res(mx+1, -1); int spare = orig[mxi]; for (int i = 0; i < n; i++) { if (a[i] != orig[i] && i != mxi) { res[a[i]] = orig[i]; } } debug(spare, res); for (int i = n+1; i < sz(res); i++) { if (res[i] == -1) { res[i] = spare; spare = i; } } for (int i = n+1; i <= mx; i++) { b[i-n-1] = res[i]; } return mx - n; } int countReplacement(int n, int inputSeq[]) { }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:8:24: warning: statement has no effect [-Wunused-value]
    8 |     #define debug(...) 42
      |                        ^~
gondola.cpp:73:5: note: in expansion of macro 'debug'
   73 |     debug(a, orig);
      |     ^~~~~
gondola.cpp:8:24: warning: statement has no effect [-Wunused-value]
    8 |     #define debug(...) 42
      |                        ^~
gondola.cpp:82:5: note: in expansion of macro 'debug'
   82 |     debug(spare, res);
      |     ^~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:96:1: warning: no return statement in function returning non-void [-Wreturn-type]
   96 | }
      | ^
#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...