Submission #141261

#TimeUsernameProblemLanguageResultExecution timeMemory
141261ngot23Bubble Sort 2 (JOI18_bubblesort2)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i) #define mp make_pair #define pii pair<int, int> #define PB push_back #define F first #define S second #define Task "" using namespace std; template <typename T > inline void MIN(T &a, T b) { if(a>b) a=b; } template <typename T > inline void MAX(T &a, T b) { if(a<b) a=b; } const int N=8005; int n, Q, a[N], t[N], L; vector <int > v; int get(int id) { int ret=0; while(id<=L) { ret+=t[id]; id+=id&(-id); } return ret; } void update(int id) { while(id) { ++t[id]; id-=id&(-id); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen(Task".inp", "r", stdin); //freopen(Task".out", "w", stdout); cin >> n >> Q; rep(i, 1, n) cin >> a[i]; while(Q--) { int id, val; cin >> id >> val; a[id+1]=val; v.clear(); v.resize(n+1, 0); rep(i, 1, n) v[i]=a[i]; sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end())-v.begin()); L=v.size(); rep(i, 1, L) t[i]=0; int mx=0; rep(i, 1, n) { int r=upper_bound(v.begin(), v.end(), a[i])-v.begin(); MAX(mx, get(r+1)); update(r); } cout << mx << '\n'; } return 0; }

Compilation message (stderr)

/tmp/ccb0tzFI.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccd1hOJ6.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
/tmp/ccb0tzFI.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status