# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
133894 | osaaateiasavtnl | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 9031 ms | 884 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define app push_back
#define ii pair <int, int>
#define mp make_pair
int get(vector <int> a) {
int n = a.size();
int ans = 0;
while (1) {
auto t = a;
sort(t.begin(), t.end());
if (t == a) return ans;
for (int i = 0; i + 1 < n; ++i) {
if (a[i + 1] < a[i]) swap(a[i], a[i + 1]);
}
++ans;
}
return ans;
}
vector <int> countScans(vector <int> a, vector <int> p, vector <int> x) {
for (auto &e : p) --e;
int n = a.size(), q = p.size();
vector <int> ans;
for (int i = 0; i < q; ++i) {
a[p[i]] = x[i];
ans.app(get(a));
}
return ans;
}
#ifdef HOME
signed main() {
//freopen("input.txt", "r", stdin);
int n, q;
cin >> n >> q;
vector <int> a(n), p(q), x(q);
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < q; ++i) cin >> p[i] >> x[i];
vector <int> ans = countScans(a, p, x);
for (int e : ans) cout << e << '\n';
}
#endif
컴파일 시 표준 에러 (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... |