# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589280 | Do_you_copy | 곤돌라 (IOI14_gondola) | C++14 | 0 ms | 0 KiB |
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 <gondola.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());
ll min(const ll &a, const ll &b){
return (a < b) ? a : b;
}
ll max(const ll &a, const ll &b){
return (a > b) ? a : b;
}
const ll Mod = 1000000007;
const ll Mod2 = 999999999989;
const int maxN = 1e5 + 1;
int n;
int valid(int N, int inputSeq[]){
n = N;
int pivot, cnt = 0, tem = INT_MAX;
for (int i = 0; i < n; ++i){
if (inputSeq[i] > n) ++cnt;
if (tem > inputSeq[i]){
tem = inputSeq[i];
pivot = i;
}
}
if (cnt == n) return 1;
//pivot is where the number one is supposed to be at
pivot = ((pivot - tem + 1) + n) % n;
for (int i = pivot; i < pivot + n; ++i){
if (inputSeq[i % n] <= n && inputSeq[i % n] != i - pivot + 1){
return 0;
}
}
return 1;
}
/*
void Init(){
int a[] = {10, 4, 3, 11, 12};
cerr << valid(5, a);
}
int main(){
if (fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
}
faster;
ll tt = 1;
//cin >> tt;
while (tt--){
Init();
}
}
*/