Submission #364443

#TimeUsernameProblemLanguageResultExecution timeMemory
364443Jarif_RahmanBubble Sort 2 (JOI18_bubblesort2)C++17
0 / 100
9094 ms1796 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; struct segtree{ int k; vector<ll> sm; segtree(int n){ k = 1; while(k <= n) k*=2; k*=2; sm.resize(k, 0LL); } void upd(int in, ll x){ in+=k/2; sm[in] = x, in/=2; while(in > 0){ sm[in] = sm[2*in] + sm[2*in+1]; in/=2; } } ll get_sum(int l, int r, int nd, int a, int b){ if(a > r || b < l) return 0LL; if(a >= l && b <= r) return sm[nd]; int md = (a+b)/2; return get_sum(l, r, 2*nd, a, md) + get_sum(l, r, 2*nd+1, md+1, b); } ll sum(int l, int r){ return get_sum(l, r, 1, 0, k/2-1); } }; vector<int> countScans(vector<int> a, vector<int> in, vector<int> v){ int n = a.size(), q = v.size(); vector<int> ans(q); for(int k = 0; k < q; k++){ a[in[k]] = v[k]; ans[k] = 0; segtree seg(n+1); vector<pair<int, int>> sth; vector<int> prm(n); for(int i = 0; i < n; i++) sth.pb({a[i], i}); sort(sth.begin(), sth.end()); for(int i = 0; i < n; i++) prm[sth[i].sc] = i; for(int i = 0; i < n; i++){ ans[k]+=seg.sum(prm[i], n); seg.upd(prm[i], 1); } } return ans; }

Compilation message (stderr)

bubblesort2.cpp: In constructor 'segtree::segtree(int)':
bubblesort2.cpp:14:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   14 |   while(k <= n) k*=2; k*=2;
      |   ^~~~~
bubblesort2.cpp:14:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   14 |   while(k <= n) k*=2; k*=2;
      |                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...