| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 893989 | vovik | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9088 ms | 860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V);
int get(std::vector<int> a) {
for (int fl = 1, c = 0; !(fl = 0); ++c) {
for (int i = 0; i + 1 < a.size(); ++i) if (a[i] > a[i + 1]) std::swap(a[i], a[i + 1]), fl = 1;
if (!fl) return c;
}
}
std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V) {
int q = X.size();
std::vector<int> answer(q);
for (int j = 0; j < q; j++) {
A[X[j]] = V[j];
answer[j] = get(A);
}
return answer;
}
#ifdef __APPLE__
#include <cstdio>
#include <cstdlib>
#include <vector>
int readInt() {
int i;
if (scanf("%d", &i) != 1) {
fprintf(stderr, "Error while reading input\n");
exit(1);
}
return i;
}
int main() {
int N, Q;
N = readInt();
Q = readInt();
std::vector<int> A(N);
for (int i = 0; i < N; i++)
A[i] = readInt();
std::vector<int> X(Q), V(Q);
for (int j = 0; j < Q; j++) {
X[j] = readInt();
V[j] = readInt();
}
std::vector<int> res = countScans(A, X, V);
for (int j = 0; j < int(res.size()); j++)
printf("%d\n", res[j]);
}
#endif
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
