Submission #1012153

# Submission time Handle Problem Language Result Execution time Memory
1012153 2024-07-01T18:16:01 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
9000 ms 856 KB
#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

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
1 Correct 108 ms 344 KB Output is correct
2 Correct 404 ms 456 KB Output is correct
3 Correct 5252 ms 344 KB Output is correct
4 Correct 5463 ms 520 KB Output is correct
5 Correct 2347 ms 516 KB Output is correct
6 Correct 360 ms 592 KB Output is correct
7 Correct 822 ms 344 KB Output is correct
8 Correct 1244 ms 348 KB Output is correct
9 Correct 2357 ms 520 KB Output is correct
10 Correct 2638 ms 512 KB Output is correct
11 Correct 2777 ms 604 KB Output is correct
12 Correct 2690 ms 348 KB Output is correct
13 Correct 2758 ms 348 KB Output is correct
14 Correct 2827 ms 512 KB Output is correct
15 Correct 2700 ms 344 KB Output is correct
16 Correct 2572 ms 516 KB Output is correct
17 Correct 2564 ms 604 KB Output is correct
18 Correct 2577 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 344 KB Output is correct
2 Correct 404 ms 456 KB Output is correct
3 Correct 5252 ms 344 KB Output is correct
4 Correct 5463 ms 520 KB Output is correct
5 Correct 2347 ms 516 KB Output is correct
6 Correct 360 ms 592 KB Output is correct
7 Correct 822 ms 344 KB Output is correct
8 Correct 1244 ms 348 KB Output is correct
9 Correct 2357 ms 520 KB Output is correct
10 Correct 2638 ms 512 KB Output is correct
11 Correct 2777 ms 604 KB Output is correct
12 Correct 2690 ms 348 KB Output is correct
13 Correct 2758 ms 348 KB Output is correct
14 Correct 2827 ms 512 KB Output is correct
15 Correct 2700 ms 344 KB Output is correct
16 Correct 2572 ms 516 KB Output is correct
17 Correct 2564 ms 604 KB Output is correct
18 Correct 2577 ms 344 KB Output is correct
19 Execution timed out 9015 ms 800 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9098 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 344 KB Output is correct
2 Correct 404 ms 456 KB Output is correct
3 Correct 5252 ms 344 KB Output is correct
4 Correct 5463 ms 520 KB Output is correct
5 Correct 2347 ms 516 KB Output is correct
6 Correct 360 ms 592 KB Output is correct
7 Correct 822 ms 344 KB Output is correct
8 Correct 1244 ms 348 KB Output is correct
9 Correct 2357 ms 520 KB Output is correct
10 Correct 2638 ms 512 KB Output is correct
11 Correct 2777 ms 604 KB Output is correct
12 Correct 2690 ms 348 KB Output is correct
13 Correct 2758 ms 348 KB Output is correct
14 Correct 2827 ms 512 KB Output is correct
15 Correct 2700 ms 344 KB Output is correct
16 Correct 2572 ms 516 KB Output is correct
17 Correct 2564 ms 604 KB Output is correct
18 Correct 2577 ms 344 KB Output is correct
19 Execution timed out 9015 ms 800 KB Time limit exceeded
20 Halted 0 ms 0 KB -