Submission #1279050

#TimeUsernameProblemLanguageResultExecution timeMemory
1279050gazizmadi11Arranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h"
#define pb push_back
// #define pf push_front
// #define F first
// #define S second
// #define all(v) v.begin(),v.end()
// #define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NE r < tl || tr < l
// #define double long double
// #define int long long s
using namespace std;
 
// const int N=2e5+7;
// const int mod=998244353;
// const int inf=2e9;

int t[N*4];
int get(int x, int v=1, int tl=1, int tr=n){
    if(tl == tr)return t[v];
    if(x <= tm)return get(x, TL)+t[v];
    else return get(x, TR)+t[v];
}
void upd(int l, int r, int v=1, int tl=1, int tr=n){
    if(DA){
        t[v]++;
        return;
    }
    if(NE)return;
    upd(l, r, TL);
    upd(l, r, TR);
}

long long count_swaps(vector<int>S){
    vector<int>a[S.size()+1];
    vector<int>b[S.size()+1];
    long long ans=0;
    for(int i=0; i < S.size(); i++){
        int x = S[i];
        if(x > 0){
            if(a[x].size()){
                ans+=i-a[x].back()-1-get(a[x].back());
                upd(a[x].back(), i);
                a[x].pop_back();
            }
            else b[x].pb(i);
        }
        else{
            x=abs(x);
            if(b[x].size()){
                ans+=i-b[x].back()-get(b[x].back());
                upd(b[x].back(), i);
                b[x].pop_back();
            }
            else a[x].pb(i);
        }
    }
    return ans;
}

// void solve(){
    
// }

// signed main(){
 
//     ios_base::sync_with_stdio(0);
//     cin.tie(0);
//     int dioz=1;
//     cin >> dioz;     
//     while(dioz--)solve();
    
// return 0;
// }

Compilation message (stderr)

shoes.cpp:22:7: error: 'N' was not declared in this scope; did you mean 'NE'?
   22 | int t[N*4];
      |       ^
      |       NE
shoes.cpp:23:42: error: 'n' was not declared in this scope
   23 | int get(int x, int v=1, int tl=1, int tr=n){
      |                                          ^
shoes.cpp: In function 'int get(int, int, int, int)':
shoes.cpp:24:24: error: 't' was not declared in this scope
   24 |     if(tl == tr)return t[v];
      |                        ^
shoes.cpp:25:34: error: 't' was not declared in this scope
   25 |     if(x <= tm)return get(x, TL)+t[v];
      |                                  ^
shoes.cpp:26:28: error: 't' was not declared in this scope
   26 |     else return get(x, TR)+t[v];
      |                            ^
shoes.cpp: At global scope:
shoes.cpp:28:50: error: 'n' was not declared in this scope
   28 | void upd(int l, int r, int v=1, int tl=1, int tr=n){
      |                                                  ^
shoes.cpp: In function 'void upd(int, int, int, int, int)':
shoes.cpp:30:9: error: 't' was not declared in this scope
   30 |         t[v]++;
      |         ^