# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793879 | 2023-07-26T07:48:37 Z | Ronin13 | Gondola (IOI14_gondola) | C++17 | 34 ms | 5264 KB |
#include "gondola.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; const ll mod = 1e9 + 9; int valid(int n, int a[]){ vector <pii> vv; set <int> st; for(int i = 0; i < n; i++){ if(st.find(a[i]) != st.end()) return 0; st.insert(a[i]); if(a[i] <= n) vv.pb({a[i], i}); } sort(vv.begin(), vv.end()); for(int i = 1; i < vv.size(); i++){ int x = vv[i].s, y = vv[i - 1].s; int dist = vv[i].f - vv[i - 1].f; if((x - y + n) % n != dist) return 0; } return 1; } //---------------------- int replacement(int n, int a[], int b[]) { int c[n]; int cur = n + 1; int ind = 0; vector <pii> vv; int x, y; for(int i = 0; i < n; i++){ if(a[i] > n) vv.pb({a[i], i}); else x = a[i], y = i; } if(vv.size() == n){ for(int i = 0; i < n; i++) c[i] = i + 1; } else{ for(int i = 0; i < n; i++){ int dist = (i - y + n) % n; c[i] = (x + dist - 1) % n + 1; } } sort(vv.begin(), vv.end()); for(int i = 0; i < vv.size(); i++){ while(cur <= vv[i].f) b[ind] = c[vv[i].s], c[vv[i].s] = cur, ind++, cur++; } return ind; } //---------------------- ll logpow(ll a, ll p){ if(p == 0) return 1; ll x = logpow(a, p / 2); x *= x, x %= mod; if(p & 1) x *= a, x %= mod; return x; } int countReplacement(int n, int a[]) { if(!valid(n, a)) return 0; vector <int> vv; int cnt = 0; for(int i = 1; i <= n; i++){ if(a[i] > n) cnt++, vv.pb(a[i]); } bool x = (cnt == n); sort(vv.begin(), vv.end()); int last = n; ll ans = 1; for(int i = 0; i < vv.size(); i++){ int c = vv[i] - last - 1; ans *= logpow(cnt, c); cnt--; ans %= mod; last = vv[i]; } if(x) ans *= (ll)n, ans %= mod; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 15 ms | 2436 KB | Output is correct |
7 | Correct | 7 ms | 624 KB | Output is correct |
8 | Correct | 25 ms | 4656 KB | Output is correct |
9 | Correct | 7 ms | 1668 KB | Output is correct |
10 | Correct | 30 ms | 5160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 12 ms | 2512 KB | Output is correct |
7 | Correct | 6 ms | 708 KB | Output is correct |
8 | Correct | 22 ms | 4728 KB | Output is correct |
9 | Correct | 7 ms | 1632 KB | Output is correct |
10 | Correct | 31 ms | 5160 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 13 ms | 1996 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 34 ms | 5264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 308 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 7 ms | 1232 KB | Output is correct |
12 | Correct | 10 ms | 1336 KB | Output is correct |
13 | Correct | 13 ms | 1508 KB | Output is correct |
14 | Correct | 7 ms | 1288 KB | Output is correct |
15 | Correct | 16 ms | 2312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 308 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 304 KB | Output is correct |
7 | Correct | 0 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 32 ms | 4556 KB | Output is correct |
10 | Incorrect | 26 ms | 3820 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 216 KB | Output is correct |
3 | Correct | 1 ms | 216 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 30 ms | 4636 KB | Output is correct |
10 | Incorrect | 25 ms | 3884 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |