Submission #1054643

#TimeUsernameProblemLanguageResultExecution timeMemory
1054643aymanrsBubble Sort 2 (JOI18_bubblesort2)C++17
17 / 100
9056 ms604 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...