답안 #469020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469020 2021-08-30T12:03:32 Z stefantaga Bubble Sort 2 (JOI18_bubblesort2) C++14
컴파일 오류
0 ms 0 KB
#include "bubblesort2.h"
#define INF 10000000000000000
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
long long  nr,n,i,v[500005];
map <pair <long long ,long long > ,long long > m;
long long arb[2000005],lazy[2000005];
void propaga(long long  st,long long  dr,long long  nod)
{
    if (st==dr)
    {
        return;
    }
    if (lazy[nod]==0)
    {
        return;
    }
    lazy[2*nod]+=lazy[nod];
    lazy[2*nod+1]+=lazy[nod];
    arb[2*nod]+=lazy[nod];
    arb[2*nod+1]+=lazy[nod];
    lazy[nod]=0;
    return;
}
long long  max1(long long  a,long long  b)
{
    if (a>b)
    {
        return a;
    }
    return b;
}
void update(long long  st,long long  dr,long long  nod,long long  ua,long long  ub,long long  val)
{
    if (ua<=st&&dr<=ub)
    {
        arb[nod]+=val;
        lazy[nod]+=val;
        return ;
    }
    propaga(st,dr,nod);
    long long  mij=(st+dr)/2;
    if (ua<=mij)
    {
        update(st,mij,2*nod,ua,ub,val);
    }
    if (mij<ub)
    {
        update(mij+1,dr,2*nod+1,ua,ub,val);
    }
    arb[nod]=max(arb[2*nod],arb[2*nod+1]);
}
std::vector<long long > countScans(std::vector<long long > A,std::vector<long long > X,std::vector<long long > val){
	long long  q=X.size();
	n=A.size();
	for (i=0;i<n;i++)
    {
        v[i+1]=A[i];
    }
    for (i=1;i<=n;i++)
    {
        m[{v[i],i}]=1;
    }
    for (i=0;i<q;i++)
    {
        m[{val[i],X[i]+1}]=1;
    }
    nr=0;
    for (auto ind: m)
    {
        nr++;
        m[ind.first]=nr;
    }
    update(1,nr,1,1,nr,-INF);
    for (i=1;i<=n;i++)
    {
        v[i]=m[{v[i],i}];
        update(1,nr,1,v[i],v[i],INF+i);
        update(1,nr,1,v[i]+1,nr,-1);
    }
    long long  j;
    vector <long long > sol;
    for (i=0;i<q;i++)
    {
        long long  poz=X[i]+1;
        update(1,nr,1,v[poz],v[poz],-INF-poz);
        update(1,nr,1,v[poz]+1,nr,1);
        v[poz]=m[{val[i],poz}];
        update(1,nr,1,v[poz],v[poz],INF+poz);
        update(1,nr,1,v[poz]+1,nr,-1);
        sol.push_back(arb[1]-1);
    }
    return sol;
}




















Compilation message

bubblesort2.cpp: In function 'std::vector<long long int> countScans(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
bubblesort2.cpp:85:16: warning: unused variable 'j' [-Wunused-variable]
   85 |     long long  j;
      |                ^
/usr/bin/ld: /tmp/ccMAfJh0.o: in function `main':
grader.cpp:(.text.startup+0x19f): 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