Submission #894663

#TimeUsernameProblemLanguageResultExecution timeMemory
894663lunaTuBubble Sort 2 (JOI18_bubblesort2)C++17
0 / 100
214 ms2100 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ff first #define ss second #define all(x) x.begin(), x.end() #include "bubblesort2.h" typedef long long ll; using namespace std; using namespace __gnu_pbds; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int N = 5e4 + 1; int A[N]; set<int> s; map<int, ordered_set> d; map<int, int> ans; int rebuild(int x, int i, int t) { ans[x] = 0; int j = *d[x].rbegin(); int mx = 0; for (auto e : s) { if (e > x) ans[x] += d[e].order_of_key(j); if (x > e && *d[e].rbegin() > i) ans[e] += t; mx = max(mx, ans[e]); } return max(mx, ans[x]); } int add(int i, int x) { int p = A[i]; d[p].erase(i); d[x].insert(i); s.insert(x); if (d[p].empty()) s.erase(p); else int k = rebuild(p, i, -1); int mx = rebuild(x, i, 1); A[i] = x; return mx; } vector<int> countScans(vector<int> a, vector<int> x, vector<int> v){ int n = a.size(); for (int i = 0; i < n; i++) { int w = add(i, a[i]); } int q = x.size(); vector<int> answer(q); for (int j = 0; j < q; j++) { answer[j] = add(x[j], v[j]); } return answer; }

Compilation message (stderr)

bubblesort2.cpp: In function 'int add(int, int)':
bubblesort2.cpp:50:14: warning: unused variable 'k' [-Wunused-variable]
   50 |     else int k = rebuild(p, i, -1);
      |              ^
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:63:13: warning: unused variable 'w' [-Wunused-variable]
   63 |         int w = add(i, a[i]);
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...