This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef ONPC
#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);
for (int i = 0; i < n; i++) a[i] = a_[i];
int mx = 0, mxi = -1;
for (int i = 0; i < n; i++) {
if (a[i] > mx) mx =a[i], mxi = 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;
}
}
vi orig(n);
for (int i = 1, j = start; i <= n; i++, j = (j+1)%n) {
orig[j] = i;
}
memset(b, -1, sizeof(int) * (mx - n + 1));
for (int i = 0; i < n; i++) {
if (orig[i] != a[i]) {
b[a[i]-1] = orig[i];
}
}
int bad = orig[mxi];
for (int i = n; i < mx; i++) {
if (b[i-n] == -1) {
b[i-n] = bad;
bad = i+1;
}
}
return mx - n;
}
int countReplacement(int n, int inputSeq[]) {
}
Compilation message (stderr)
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:94:1: warning: no return statement in function returning non-void [-Wreturn-type]
94 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |