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 "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 |
---|
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... |