# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
809124 | 2023-08-05T17:59:50 Z | OrazB | 곤돌라 (IOI14_gondola) | C++14 | 42 ms | 10148 KB |
#include <bits/stdc++.h> #include "gondola.h" using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second const int N = 1e5+5; int T[N]; int valid(int n, int A[]){ map<int,int> mp; int pos = -1; for (int i = 0; i < n; i++){ if (mp[A[i]]++) return 0; if (A[i] <= n){pos = i;break;} } if (pos == -1) return 1; int x = A[pos]; for (int i = pos; i < n; i++){ if (i > pos and mp[A[i]]++) return 0; if (A[i] <= n and A[i] != x) return 0; x++; if (x == n+1) x = 1; } return 1; } int replacement(int n, int A[], int replacementSeq[]){ int x = valid(n, A); for (int i = 0; i < n; i++){ T[i] = i+1; } int pos = -1; for (int i = 0; i < n; i++){ if (A[i] <= n){pos = i;break;} } if (pos != -1){ int x = A[pos]; for (int i = pos; i >= 0; i--){ T[i] = x; x--; if (!x) x = n; } x = A[pos]; for (int i = pos; i < n; i++){ T[i] = x; x++; if (x == n+1) x = 1; } } int mx = 0, ind = 0; map <int,int> idx; for (int i = 0; i < n; i++){ idx[A[i]] = i+1; if (mx < A[i]){ mx = A[i]; ind = i; } } for (int i = n+1; i <= mx; i++){ if (idx[i]){ replacementSeq[i-n-1] = T[idx[i]-1]; }else{ replacementSeq[i-n-1] = T[ind]; T[ind] = i; } } return mx-n; } const ll mod = 1000000009; int F(int x, int y){ int res = 1; while(y){ if (y&1) res = (res*1ll*x)%mod; x = (x*1ll*x)%mod; y /= 2; } return res; } int countReplacement(int n, int A[]){ if (!valid(n, A)) return 0; vector<int> vec; int ans = 1; for (int i = 0; i < n; i++){ if (A[i] > n) vec.pb(A[i]); } sort(all(vec)); int cnt = vec.size(); if (cnt == n) ans = n; int lst = n; for (int i = 0; i < vec.size(); i++){ ans = (ans*1ll*F(cnt, vec[i]-lst-1)); lst = vec[i]; } return ans; } // int main () // { // ios::sync_with_stdio(false); // cin.tie(0); // int n; // cin >> n; // int A[n]; // for (int i = 0; i < n; i++) cin >> A[i]; // cout << countReplacement(n, A); // }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 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 | 1 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 308 KB | Output is correct |
6 | Correct | 8 ms | 2388 KB | Output is correct |
7 | Correct | 7 ms | 1096 KB | Output is correct |
8 | Correct | 15 ms | 4332 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 17 ms | 4904 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 2388 KB | Output is correct |
7 | Correct | 6 ms | 1108 KB | Output is correct |
8 | Correct | 14 ms | 4292 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 17 ms | 4928 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 5 ms | 596 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 6 ms | 1108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 308 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 468 KB | Output is correct |
9 | Correct | 1 ms | 468 KB | Output is correct |
10 | Correct | 1 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 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 | 340 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 1 ms | 440 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 23 ms | 4948 KB | Output is correct |
12 | Correct | 27 ms | 5724 KB | Output is correct |
13 | Correct | 31 ms | 4940 KB | Output is correct |
14 | Correct | 27 ms | 5024 KB | Output is correct |
15 | Correct | 42 ms | 10148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 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 | Incorrect | 0 ms | 312 KB | Integer 1162261467 violates the range [0, 1000000008] |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Incorrect | 1 ms | 312 KB | Integer 1162261467 violates the range [0, 1000000008] |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 316 KB | Output is correct |
5 | Incorrect | 0 ms | 312 KB | Integer 1162261467 violates the range [0, 1000000008] |
6 | Halted | 0 ms | 0 KB | - |