# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281573 | 2020-08-23T08:31:56 Z | SamAnd | Gondola (IOI14_gondola) | C++17 | 43 ms | 5032 KB |
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) typedef long long ll; const int N = 100005, M = 1000000009; int n; int a[N]; int valid(int n, int inputSeq[]) { ::n = n; for (int i = 0; i < n; ++i) a[i] = inputSeq[i]; set<int> s; for (int i = 0; i < n; ++i) s.insert(a[i]); if (sz(s) != n) return 0; int minu = M; int mini; for (int i = 0; i < n; ++i) { if (a[i] < minu) { minu = a[i]; mini = i; } } int q = 0; for (int i = mini; i < n; ++i) { if (a[i] <= n) { if (a[i] != minu + q) return 0; } ++q; } for (int i = 0; i < mini; ++i) { if (a[i] <= n) { if (a[i] != minu + q) return 0; } ++q; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { ::n = n; for (int i = 0; i < n; ++i) a[i] = gondolaSeq[i]; int m = 0; vector<pair<int, int> > v; for (int i = 0; i < n; ++i) { if (a[i] > n) { v.push_back(m_p(a[i], i)); } } sort(all(v)); reverse(all(v)); /////////////////////////////////////////// int minu = M; int mini; for (int i = 0; i < n; ++i) { if (a[i] < minu) { minu = a[i]; mini = i; } } if (minu > n) { minu = 1; } for (int i = mini; i < n; ++i) { if (minu > n) minu = 1; a[i] = minu; ++minu; } for (int i = 0; i < mini; ++i) { if (minu > n) minu = 1; a[i] = minu; ++minu; } /////////////////////////////////////////// int u = n + 1; while (!v.empty()) { if (u == v.back().fi) { replacementSeq[m++] = a[v.back().se]; a[v.back().se] = u; v.pop_back(); } else { replacementSeq[m++] = a[v.back().se]; a[v.back().se] = u; } ++u; } return m; } //---------------------- int countReplacement(int n, int inputSeq[]) { return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 13 ms | 2432 KB | Output is correct |
7 | Correct | 35 ms | 3968 KB | Output is correct |
8 | Correct | 26 ms | 4224 KB | Output is correct |
9 | Correct | 8 ms | 1536 KB | Output is correct |
10 | Correct | 29 ms | 4864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 13 ms | 2432 KB | Output is correct |
7 | Correct | 34 ms | 3968 KB | Output is correct |
8 | Correct | 28 ms | 4224 KB | Output is correct |
9 | Correct | 8 ms | 1568 KB | Output is correct |
10 | Correct | 31 ms | 4984 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 17 ms | 2304 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 43 ms | 5032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 372 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 12 ms | 1408 KB | Output is correct |
12 | Correct | 14 ms | 1536 KB | Output is correct |
13 | Correct | 18 ms | 1676 KB | Output is correct |
14 | Correct | 12 ms | 1396 KB | Output is correct |
15 | Correct | 25 ms | 2424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |