| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1123053 | SulA | Gondola (IOI14_gondola) | C++20 | 0 ms | 0 KiB | 
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
//#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, vector<int> a) {
    deque<int> s;
    int val = -1;
    for (int i = 0; i < n; i++) {
        s.push_back(--a[i]);
        if (a[i] < n) val = i;
    }
    if (val == -1) return true;
    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;
}
//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);
//}
