#include "bubblesort2.h"
#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size();
std::vector<int> ans(Q);
int n = A.size();
int cop[n];
for (int j=0;j<Q;j++) {
A[X[j]] = V[j];
bool bad = 0;
for(int i = 0;i < n;i++) {
cop[i]=A[i];
bad |= i && cop[i]<cop[i-1];
}
ans[j]=0;
while(bad){
ans[j]++;
bad = 0;
for(int i = 0;i < n-1;i++) {
if(cop[i] > cop[i+1]) {
swap(cop[i],cop[i+1]);
}
bad |= i && cop[i]<cop[i-1];
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
424 KB |
Output is correct |
2 |
Correct |
424 ms |
348 KB |
Output is correct |
3 |
Correct |
5714 ms |
464 KB |
Output is correct |
4 |
Correct |
5747 ms |
468 KB |
Output is correct |
5 |
Correct |
2438 ms |
348 KB |
Output is correct |
6 |
Correct |
387 ms |
472 KB |
Output is correct |
7 |
Correct |
967 ms |
348 KB |
Output is correct |
8 |
Correct |
1366 ms |
468 KB |
Output is correct |
9 |
Correct |
2398 ms |
468 KB |
Output is correct |
10 |
Correct |
3328 ms |
468 KB |
Output is correct |
11 |
Correct |
3289 ms |
468 KB |
Output is correct |
12 |
Correct |
3329 ms |
472 KB |
Output is correct |
13 |
Correct |
3383 ms |
468 KB |
Output is correct |
14 |
Correct |
3256 ms |
468 KB |
Output is correct |
15 |
Correct |
3330 ms |
468 KB |
Output is correct |
16 |
Correct |
3341 ms |
356 KB |
Output is correct |
17 |
Correct |
3260 ms |
468 KB |
Output is correct |
18 |
Correct |
3360 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
424 KB |
Output is correct |
2 |
Correct |
424 ms |
348 KB |
Output is correct |
3 |
Correct |
5714 ms |
464 KB |
Output is correct |
4 |
Correct |
5747 ms |
468 KB |
Output is correct |
5 |
Correct |
2438 ms |
348 KB |
Output is correct |
6 |
Correct |
387 ms |
472 KB |
Output is correct |
7 |
Correct |
967 ms |
348 KB |
Output is correct |
8 |
Correct |
1366 ms |
468 KB |
Output is correct |
9 |
Correct |
2398 ms |
468 KB |
Output is correct |
10 |
Correct |
3328 ms |
468 KB |
Output is correct |
11 |
Correct |
3289 ms |
468 KB |
Output is correct |
12 |
Correct |
3329 ms |
472 KB |
Output is correct |
13 |
Correct |
3383 ms |
468 KB |
Output is correct |
14 |
Correct |
3256 ms |
468 KB |
Output is correct |
15 |
Correct |
3330 ms |
468 KB |
Output is correct |
16 |
Correct |
3341 ms |
356 KB |
Output is correct |
17 |
Correct |
3260 ms |
468 KB |
Output is correct |
18 |
Correct |
3360 ms |
468 KB |
Output is correct |
19 |
Execution timed out |
9056 ms |
604 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9052 ms |
604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
424 KB |
Output is correct |
2 |
Correct |
424 ms |
348 KB |
Output is correct |
3 |
Correct |
5714 ms |
464 KB |
Output is correct |
4 |
Correct |
5747 ms |
468 KB |
Output is correct |
5 |
Correct |
2438 ms |
348 KB |
Output is correct |
6 |
Correct |
387 ms |
472 KB |
Output is correct |
7 |
Correct |
967 ms |
348 KB |
Output is correct |
8 |
Correct |
1366 ms |
468 KB |
Output is correct |
9 |
Correct |
2398 ms |
468 KB |
Output is correct |
10 |
Correct |
3328 ms |
468 KB |
Output is correct |
11 |
Correct |
3289 ms |
468 KB |
Output is correct |
12 |
Correct |
3329 ms |
472 KB |
Output is correct |
13 |
Correct |
3383 ms |
468 KB |
Output is correct |
14 |
Correct |
3256 ms |
468 KB |
Output is correct |
15 |
Correct |
3330 ms |
468 KB |
Output is correct |
16 |
Correct |
3341 ms |
356 KB |
Output is correct |
17 |
Correct |
3260 ms |
468 KB |
Output is correct |
18 |
Correct |
3360 ms |
468 KB |
Output is correct |
19 |
Execution timed out |
9056 ms |
604 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |