답안 #914429

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914429 2024-01-22T05:54:53 Z manizare Bubble Sort 2 (JOI18_bubblesort2) C++17
컴파일 오류
0 ms 0 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double
#define int long long
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
using namespace std ;   
const int maxn = 1e6 + 10 , inf= 2e9 , mod = 1e9 + 7 , sq = 360 ;
int MX = 20000 ;
struct fenwick{
    int fen[2*MX] ;
    void upd(int x ,int w){
        x++;
        while(x <= MX){
            fen[x]+=w;
            x+=x&-x; 
        }
    }
    int que(int x){
        x++;int ans =0 ;
        while(x){   
            ans+=fen[x];
            x-=x&-x;
        }
        return ans ;
    }
}f;

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
    int n = sz(A) , q =sz(X) ;     
    vector <int> res(q) , cm;
    rep(i , 0 , n-1)cm.pb(A[i]);
    rep(i , 0 ,q-1)cm.pb(V[i]) ;
    sort(all(cm)) ;
    cm.resize(unique(all(cm))-cm.begin()) ;
    rep(i , 0 , n-1){
        A[i] = lower_bound(all(cm) , A[i]) -cm.begin() ;
    }
    rep(i , 0 , q-1){
        A[X[i]] = lower_bound(all(cm),V[i])-cm.begin() ;
        int ans =0 ;
        rep(j , 0 , n-1){
            ans = max(ans , j-f.que(A[j])) ;
            f.upd(A[j] , 1);
        }
        rep(i , 0 , sz(cm))f.fen[i]=0;
        res[i]=ans;
    }
    return res; 
}


/*
signed main(){
    ios::sync_with_stdio(0);cin.tie(0); 
    int n , q ;
    cin >> n >> q;
    vector <int> a ;
    rep(i , 1, n){
        int x;
        cin >> x ;
        a.pb(x);
    }
    vector <int> X , V ;
    rep(i , 1, q){
        int x, v;
        cin >> x>> v ;
        X.pb(x);V.pb(v);
    }
    vector <int> ans = countScans(a,X,V) ;
    for(int x : ans){
        cout << x << "\n" ;
    }
    return 0;   
}
*/
/*

*/

Compilation message

bubblesort2.cpp:19:17: error: array bound is not an integer constant before ']' token
   19 |     int fen[2*MX] ;
      |                 ^
bubblesort2.cpp: In member function 'void fenwick::upd(long long int, long long int)':
bubblesort2.cpp:23:13: error: 'fen' was not declared in this scope
   23 |             fen[x]+=w;
      |             ^~~
bubblesort2.cpp: In member function 'long long int fenwick::que(long long int)':
bubblesort2.cpp:30:18: error: 'fen' was not declared in this scope
   30 |             ans+=fen[x];
      |                  ^~~
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:54:30: error: 'struct fenwick' has no member named 'fen'
   54 |         rep(i , 0 , sz(cm))f.fen[i]=0;
      |                              ^~~