#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int N, vector<int> A) {
int cnt = 0;
while (1) {
bool move = 0;
for (int i = 0; i+1 < N; i++) {
if (A[i] > A[i+1]) {
swap(A[i], A[i+1]);
move = 1;
}
}
if (!move) break;
cnt++;
}
return cnt;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
int N = A.size();
int Q = X.size();
vector<int> ans(Q);
for (int j = 0; j < Q; j++) {
A[X[j]] = V[j];
ans[j] = solve(N, A);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
348 KB |
Output is correct |
2 |
Correct |
365 ms |
344 KB |
Output is correct |
3 |
Correct |
5333 ms |
476 KB |
Output is correct |
4 |
Correct |
5294 ms |
344 KB |
Output is correct |
5 |
Correct |
2291 ms |
344 KB |
Output is correct |
6 |
Correct |
304 ms |
472 KB |
Output is correct |
7 |
Correct |
842 ms |
472 KB |
Output is correct |
8 |
Correct |
1250 ms |
472 KB |
Output is correct |
9 |
Correct |
2309 ms |
472 KB |
Output is correct |
10 |
Correct |
2640 ms |
348 KB |
Output is correct |
11 |
Correct |
2718 ms |
344 KB |
Output is correct |
12 |
Correct |
2721 ms |
472 KB |
Output is correct |
13 |
Correct |
2725 ms |
344 KB |
Output is correct |
14 |
Correct |
2746 ms |
348 KB |
Output is correct |
15 |
Correct |
2551 ms |
348 KB |
Output is correct |
16 |
Correct |
2513 ms |
468 KB |
Output is correct |
17 |
Correct |
2535 ms |
348 KB |
Output is correct |
18 |
Correct |
2633 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
348 KB |
Output is correct |
2 |
Correct |
365 ms |
344 KB |
Output is correct |
3 |
Correct |
5333 ms |
476 KB |
Output is correct |
4 |
Correct |
5294 ms |
344 KB |
Output is correct |
5 |
Correct |
2291 ms |
344 KB |
Output is correct |
6 |
Correct |
304 ms |
472 KB |
Output is correct |
7 |
Correct |
842 ms |
472 KB |
Output is correct |
8 |
Correct |
1250 ms |
472 KB |
Output is correct |
9 |
Correct |
2309 ms |
472 KB |
Output is correct |
10 |
Correct |
2640 ms |
348 KB |
Output is correct |
11 |
Correct |
2718 ms |
344 KB |
Output is correct |
12 |
Correct |
2721 ms |
472 KB |
Output is correct |
13 |
Correct |
2725 ms |
344 KB |
Output is correct |
14 |
Correct |
2746 ms |
348 KB |
Output is correct |
15 |
Correct |
2551 ms |
348 KB |
Output is correct |
16 |
Correct |
2513 ms |
468 KB |
Output is correct |
17 |
Correct |
2535 ms |
348 KB |
Output is correct |
18 |
Correct |
2633 ms |
472 KB |
Output is correct |
19 |
Execution timed out |
9040 ms |
600 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9076 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
348 KB |
Output is correct |
2 |
Correct |
365 ms |
344 KB |
Output is correct |
3 |
Correct |
5333 ms |
476 KB |
Output is correct |
4 |
Correct |
5294 ms |
344 KB |
Output is correct |
5 |
Correct |
2291 ms |
344 KB |
Output is correct |
6 |
Correct |
304 ms |
472 KB |
Output is correct |
7 |
Correct |
842 ms |
472 KB |
Output is correct |
8 |
Correct |
1250 ms |
472 KB |
Output is correct |
9 |
Correct |
2309 ms |
472 KB |
Output is correct |
10 |
Correct |
2640 ms |
348 KB |
Output is correct |
11 |
Correct |
2718 ms |
344 KB |
Output is correct |
12 |
Correct |
2721 ms |
472 KB |
Output is correct |
13 |
Correct |
2725 ms |
344 KB |
Output is correct |
14 |
Correct |
2746 ms |
348 KB |
Output is correct |
15 |
Correct |
2551 ms |
348 KB |
Output is correct |
16 |
Correct |
2513 ms |
468 KB |
Output is correct |
17 |
Correct |
2535 ms |
348 KB |
Output is correct |
18 |
Correct |
2633 ms |
472 KB |
Output is correct |
19 |
Execution timed out |
9040 ms |
600 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |