Submission #769332

#TimeUsernameProblemLanguageResultExecution timeMemory
769332Dan4LifeBubble Sort 2 (JOI18_bubblesort2)C++17
0 / 100
9007 ms5212 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define pb push_back using vi = vector<int>; #define sz(a) (int)a.size() #define all(a) begin(a),end(a) const int mxN = (int)1e2+10; template<class T> using Tree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; Tree<int> S[mxN]; vi countScans(vi A, vi X, vi V){ int q = sz(X), n = sz(A); vi ans, a(all(A)); for(int i = 0; i < n; i++) S[a[i]].insert(i); for(int _ = 0; _ < q; _++){ S[a[X[_]]].erase(X[_]); a[X[_]] = V[_]; S[a[X[_]]].insert(X[_]); int tot = 0; for(int i = 1; i < mxN; i++){ if(S[i].empty()) continue; int sum = 0; int p = *(--S[i].end()); for(int j = i+1; j < mxN; j++){ if(S[j].empty()) continue; sum+=S[j].order_of_key(p); } auto itr = *(--S[i].end()); tot = max(tot, sum); } ans.pb(tot); } return ans; }

Compilation message (stderr)

bubblesort2.cpp: In function 'vi countScans(vi, vi, vi)':
bubblesort2.cpp:28:9: warning: unused variable 'itr' [-Wunused-variable]
   28 |    auto itr = *(--S[i].end());
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...