# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
428570 | 2021-06-15T12:56:30 Z | markthitrin | 곤돌라 (IOI14_gondola) | C++14 | 57 ms | 5060 KB |
#include "gondola.h" #include <map> #include <queue> #include <algorithm> #include <iostream> class name { public: int value; int base; bool operator<(const name& b) const{ return value > b.value; } void operator=(const name& b){ value = b.value; base = b.base; } }put_in; int mod = 1000000009; int valid(int n, int inputSeq[]) { std::map<int,bool> g; int max = 0; int find_min = 2000000000; int min_pos = 0; for(int q = 0 ;q<n;q++){ if(g[inputSeq[q]]) return 0; g[inputSeq[q]] = true; if(find_min > inputSeq[q]){ find_min = inputSeq[q]; min_pos = q; } } if(find_min > n) return 1; int last_pos = min_pos - find_min; for(int q = min_pos;q < min_pos + n;q++){ if(max < inputSeq[q % n] && inputSeq[q % n] <= n){ if(inputSeq[q % n] - max != q - last_pos) return 0; max = inputSeq[q % n]; inputSeq[q % n] = 2000000000; last_pos = q; } } for(int q = 0 ;q<n;q++){ if(inputSeq[q] <= n) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { std::priority_queue<name> g; int max = 0; for(int q = 0 ;q<n;q++){ max = std::max(max,gondolaSeq[q]); } int find_min = 2000000000; int min_pos; for(int q = 0 ;q<n;q++){ if(find_min > gondolaSeq[q]){ find_min = gondolaSeq[q]; min_pos = q; } } if(find_min > n) min_pos = 0; else { min_pos -= find_min - 1; if(min_pos < 0) min_pos += n; } for(int q = min_pos;q<min_pos + n;q++){ put_in.value = gondolaSeq[q % n]; put_in.base = q + 1 - min_pos; g.push(put_in); } int cnt = 0; int last_value = n; while(!g.empty()){ put_in = g.top(); g.pop(); if(put_in.value <= n) continue; replacementSeq[cnt++] = put_in.base; for(int q = last_value + 1;q<put_in.value;q++){ replacementSeq[cnt++] = q; } last_value = put_in.value; } return cnt; } //---------------------- bool valid_g(std::vector<int> inputSeq){ int n = inputSeq.size(); std::map<int,bool> g; int max = 0; int find_min = 2000000000; int min_pos = 0; for(int q = 0 ;q<n;q++){ if(g[inputSeq[q]]) return false; g[inputSeq[q]] = true; if(find_min > inputSeq[q]){ find_min = inputSeq[q]; min_pos = q; } } if(find_min > n) return false; int last_pos = min_pos - find_min; for(int q = min_pos;q < min_pos + n;q++){ if(max < inputSeq[q % n] && inputSeq[q % n] <= n){ if(inputSeq[q % n] - max != q - last_pos) return false; max = inputSeq[q % n]; inputSeq[q % n] = 2000000000; last_pos = q; } } for(int q = 0 ;q<n;q++){ if(inputSeq[q] <= n) return false; } return true; } long long power(long long a,int number){ if(number == 0) return 1; if(number == 1) return a; long long ans = 1; if(number% 2) ans *= a; ans %= mod; ans *= power(a,number/2); ans%= mod; ans*= power(a,number/2); ans%=mod; return ans; } int countReplacement(int n, int inputSeq[]) { std::vector<int> copy; for(int q = 0 ;q<n;q++){ copy.push_back(inputSeq[q]); } if(!valid_g(copy)) return 0; long long ans = 1; std::vector<int> h; for(int q = 0 ;q<n;q++){ if(inputSeq[q] > n) h.push_back(inputSeq[q]); } if(h.size() == 0) return 1; std::sort(h.begin(),h.end()); int last_value = n; int cnt =0; while(h.size() != cnt) { ans *= power(h.size() - cnt,h[cnt] - last_value - 1); ans %= mod; last_value = h[cnt]; cnt++; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 15 ms | 2428 KB | Output is correct |
7 | Correct | 15 ms | 1100 KB | Output is correct |
8 | Correct | 31 ms | 4308 KB | Output is correct |
9 | Correct | 12 ms | 1496 KB | Output is correct |
10 | Correct | 36 ms | 4936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 21 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1100 KB | Output is correct |
8 | Correct | 31 ms | 4336 KB | Output is correct |
9 | Correct | 9 ms | 1484 KB | Output is correct |
10 | Correct | 37 ms | 4892 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 20 ms | 2304 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 49 ms | 5060 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 18 ms | 2224 KB | Output is correct |
12 | Correct | 20 ms | 2244 KB | Output is correct |
13 | Correct | 18 ms | 1452 KB | Output is correct |
14 | Correct | 18 ms | 2116 KB | Output is correct |
15 | Correct | 24 ms | 2308 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 57 ms | 5000 KB | Output is correct |
10 | Correct | 38 ms | 4160 KB | Output is correct |
11 | Correct | 14 ms | 1740 KB | Output is correct |
12 | Correct | 18 ms | 1996 KB | Output is correct |
13 | Incorrect | 4 ms | 716 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 48 ms | 5012 KB | Output is correct |
10 | Correct | 41 ms | 4212 KB | Output is correct |
11 | Correct | 15 ms | 1692 KB | Output is correct |
12 | Correct | 21 ms | 1996 KB | Output is correct |
13 | Incorrect | 4 ms | 716 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |