#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int N=500010;
#include "bubblesort2.h"
int lds(vector<int> &a){
set<int> st;
forv(i,a){
if(st.empty() || -i>*st.rbegin()){
st.insert(-i);
} else{
st.erase(st.lower_bound(-i));
st.insert(-i);
}
}
return st.size();
}
int brute(vector<int> &a){
for(int ans=0;;){
int has=0;
forinc(i,1,a.size()-1){
if(a[i]<a[i-1]){
has=1;
swap(a[i],a[i-1]);
}
}
if(!has) return ans+1;
ans++;
}
}
vector<int> countScans(vector<int> a,vector<int> x,vector<int> v){
vector<int> res;
forinc(i,0,x.size()-1){
a[x[i]]=v[i];
res.push_back(brute(a)-1);
}
return res;
}
/**
main(){
#define task "TASK"
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
vector<int> a={1,2,3,4};
vector<int> x={0,2};
vector<int> y={3,1};
forv(i,countScans(a,x,y))
cout<<i<<" ";
/**
n=in;
forinc(i,1,n) a[i]=in;
for(int ans=0;;){
int has=0;
forinc(i,2,n){
if(a[i]<a[i-1]){
has=1;
swap(a[i],a[i-1]);
}
}
if(!has) return cout<<ans,0;
ans++;
}
}
*/
Compilation message
bubblesort2.cpp:75:5: warning: "/*" within comment [-Wcomment]
/**
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9012 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |