#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include"bubblesort2.h"
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
using namespace std;
typedef int ll;
typedef vector<ll> vll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll solve(vll a){
ll n=a.size(),ans=0;
while(1){
bool done=0;
for(int i=0;i<=n-2;i++){
if(a[i]>a[i+1]){
swap(a[i],a[i+1]);
done=1;
}
}
if(!done)break;
ans++;
}
return ans;
}
vll countScans(vll a,vll x,vll v){
ll n=a.size(),q=x.size();
if(n>2000)return a;
vll fans;
rep(k,q){
a[x[k]]=v[k];
fans.push_back(solve(a));
}
return fans;
}
/*int main(){
ll n,q;
cin>>n>>q;
vll a(n),x(q),v(q);
rep(i,n)cin>>a[i];
rep(i,q)cin>>x[i]>>v[i];
vll res=countScans(a,x,v);
for(auto t:res)cout<<t<<endl;
}
*/
Compilation message
bubblesort2.cpp:9:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("O3")
bubblesort2.cpp:10:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("unroll-loops")
bubblesort2.cpp:11:0: warning: ignoring #pragma gcc target [-Wunknown-pragmas]
#pragma gcc target("avx2,see4")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
388 KB |
Output is correct |
2 |
Correct |
970 ms |
504 KB |
Output is correct |
3 |
Execution timed out |
9071 ms |
632 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
388 KB |
Output is correct |
2 |
Correct |
970 ms |
504 KB |
Output is correct |
3 |
Execution timed out |
9071 ms |
632 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
388 KB |
Output is correct |
2 |
Correct |
970 ms |
504 KB |
Output is correct |
3 |
Execution timed out |
9071 ms |
632 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |