Submission #438733

#TimeUsernameProblemLanguageResultExecution timeMemory
438733CSQ31Bubble Sort 2 (JOI18_bubblesort2)C++17
Compilation error
0 ms0 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define sz(a) (int)(a.size()); typedef pair<int,int> pii; vector<int>bit(100000); int n; void upd(int pos,int val){ for(int i=pos;i<=n;i+=i&(-i))bit[i]+=val; } int query(int pos){ int res = 0; while(pos){ res+=bit[pos]; pos-=pos&(-pos); } return res; } vector<int> countScans(vector<int> a,vector<int> x,vector<int>v){ int q=sz(x); n = sz(a); vector<int> answer(q); for (int j=0;j<q;j++) { for(int i=1;i<=n;i++)bit[i] = 0; a[x[j]] = v[j]; for(int i=0;i<n;i++){b[i].fi = a[i];b[i].se = i+1;} sort(b.begin(),b.end()); int mx = 0; for(int i=n-1;i>=0;i--){ mx = max(query(b[i].se),mx); upd(b[i].se,1); } answer[j] = mx; } return answer; }

Compilation message (stderr)

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:28:24: error: 'b' was not declared in this scope
   28 |   for(int i=0;i<n;i++){b[i].fi = a[i];b[i].se = i+1;}
      |                        ^
bubblesort2.cpp:29:8: error: 'b' was not declared in this scope
   29 |   sort(b.begin(),b.end());
      |        ^