Submission #370385

# Submission time Handle Problem Language Result Execution time Memory
370385 2021-02-23T23:09:23 Z jainbot27 Kralj (COCI16_kralj) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define F0R(x, z) FOR(x, 0, z)

const int mxN = 5e5+10;

int n;
int a[mxN];
int st[mxN];
int par[mxN];
vector<int> v[mxN];
int nums[mxN];
int ans = 0;

int p(int q){
    if(par[q]==q) return par[q];
    return par[q]=p(par[q]);
}

void comb(int e1, int e2){
    e1 = p(e1); e2 = p(e2);
    par[e2] = e1;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    F0R(i, n){
        par[i] = i;
        cin >> a[i]; a[i]--;
    }
    F0R(i, n){
        cin >> st[i];
    }
    F0R(i, n){
        int x; cin >> x;
        v[a[i]].pb(x);
    }
    int q = 0;
    F0R(i, 2*n){
        bool good = 1;
        if(q>0){
            comb((i-1)%n, i%n);
            q--;
            good = 0;
        }
        q += max(siz(v[i%n])-good,0);
    }
    F0R(i, n){
        nums[par[i]]++;
    }
    F0R(i, n){
        set<int> al;
        FOR(j, i, i+nums[i]){
            trav(x, v[j%n]){
                al.insert(x);
            }
            auto it = al.lower_bound(st[j%n]);
            if(it==al.end()) al.erase(al.begin());
            else{
                ans++;
                al.erase(it);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Compilation message

kralj.cpp: In function 'int32_t main()':
kralj.cpp:39:17: error: 'class std::vector<int>' has no member named 'pb'
   39 |         v[a[i]].pb(x);
      |                 ^~
kralj.cpp:49:18: error: 'siz' was not declared in this scope; did you mean 'sin'?
   49 |         q += max(siz(v[i%n])-good,0);
      |                  ^~~
      |                  sin
kralj.cpp:57:18: error: 'x' was not declared in this scope
   57 |             trav(x, v[j%n]){
      |                  ^
kralj.cpp:57:13: error: 'trav' was not declared in this scope
   57 |             trav(x, v[j%n]){
      |             ^~~~