#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include "gondola.h"
//#pragma GCC target("popcnt")
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<int, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;
#define popcount __builtin_popcountll
#define all(a) (a).begin(), (a).end()
int valid(int n, int a[]) {
set<int> dis;
for (int i = 0; i < n; dis.insert(a[i++]));
if (dis.size() < n) return 0;
deque<int> s;
int val = -1;
for (int i = 0; i < n; i++) {
s.push_back(--a[i]);
if (a[i] < n) val = a[i];
}
if (val == -1) return 1;
while (s[val] != val) {
s.push_front(s.back());
s.pop_back();
}
for (int i = 0; i < n; i++) if (s[i] < n && s[i] != i) return 0;
return 1;
}
int replacement(int n, int a[], int b[]) {
return valid(n, a);
}
int countReplacement(int n, int a[]) {
return 69;
}
//signed main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
//
// int n; cin >> n;
// vector<int> a(n);
// for (int& x : a) cin >> x;
// cout << valid(n, a);
//}
# | 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... |