답안 #141268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141268 2019-08-07T08:35:19 Z ngot23 Bubble Sort 2 (JOI18_bubblesort2) C++11
컴파일 오류
0 ms 0 KB
#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, id[N], val[N];
vector <int > v, ans;

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);
    }
}

vector <int > countScans(int a[], int id[], int val[]) {
    vector <int > ret(Q, 0);

    rep(j, 1, Q) {

        a[id[j]+1]=val[j];
        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);
        }
        ret[j-1]=mx;
    }
    return ret;
}

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];
    rep(i, 1, Q) cin >> id[i] >> val[i];
    ans=countScans(a, id, val);
    for(int xx:ans) cout << xx << '\n';
    return 0;
}

Compilation message

/tmp/ccei3HHR.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccsl1o75.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
/tmp/ccei3HHR.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