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 <bits/stdc++.h>
// #include "bubblesort2.h"
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
#define pq_min(a) priority_queue<a, vector<a>, greater<a>>
#define fls cout.flush()
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>;using ii = pair<int,int>;using mii = map<int,int>;
void valid(ll in){cout<<((in)?"YES\n":"NO\n");}
ll lcm(ll a, ll b){return (a/gcd(a,b))*b;}
struct segtree{
vi st;
int n;
segtree(){}
segtree(int n):n(n){st.resize(4*n+4,0);}
void update(int i, int v){update(1,0,n-1,i,v);}
void update(int nodo, int l, int r, int i, int v){
if(l==r)st[nodo] = v;
else{
int m = (l+r)/2;
if(i<=m)update(nodo*2,l,m,i,v);
else update(nodo*2+1,m+1,r,i,v);
st[nodo] = max(st[nodo*2],st[nodo*2+1]);
}
}
int query(int l, int r){return query(1,0,n-1,l,r);}
int query(int nodo, int l, int r, int i, int j){
if(l>j||r<i) return 1e9 + 1;
if(l>=i&&r<=j)return st[nodo];
int m = (l+r)/2;
return max(query(nodo*2, l,m,i,j),query(nodo*2+1,m+1,r,i,j));
}
int next_gr(int i, int a){
int l = i+1, r = n-1;
while(l<=r){
int m = (l+r)/2;
if(query(i+1, m) >= a)r = m-1;
else l = m+1;
}
return l;
}
}st;
vi countScans(vi a,vi X,vi V){
int q = sz(X), n = sz(a);
vi ans(q,0);
fo(i,q){
int cn = 0;
a[X[i]] = V[i];
vi b = a;
while(!is_sorted(all(b))){
ans[i] ++;
fo(j, n-1){
if(b[j] > b[j+1])
swap(b[j], b[j+1]);
}
}
}
return ans;
}
Compilation message (stderr)
bubblesort2.cpp: In function 'vi countScans(vi, vi, vi)':
bubblesort2.cpp:63:13: warning: unused variable 'cn' [-Wunused-variable]
63 | int cn = 0;
| ^~
# | 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... |