Submission #155359

#TimeUsernameProblemLanguageResultExecution timeMemory
155359Sasuke0004Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pb push_back
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define tree ll h,ll l,ll r,ll L,ll R
using namespace std;
ll sg[4000006],fx[4000006],n,ans;
vector<ll>v[4000006];
void upd(tree)
{
    if(l>r)return;
    if(l>R)return;
    if(L>r)return;
    if(l==r)
    {
        sg[h]=sg[h]^(1);
        return;
    }
    upd(left);
    upd(right);
    sg[h]=sg[2*h]+sg[2*h+1];
}
ll get(tree)
{
    if(l>r)return 0;
    if(l>R)return 0;
    if(L>r)return 0;
    if(l>=L && r<=R)return sg[h];
    else return (get(left)+get(right));
}
int64_t count_swaps(vector<int> x)
{
    n=x.size();
    for(ll i=0;i<n;i++)
    {
      if(x[i]<0)
      {
        v2.pb(i);
      }
      else
      {
        v1.pb(i);
      }
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<int(v[i].size());j++)
        {
            if(v1[i][j]>v2[i][j]){ans++;swap(v1[i][j],v2[i][j]);}
            fx[v1[i][j]]=v2[i+n][j];
        }
    }
    for(ll i=0;i<n;i++)
    {
        upd(1,0,n-1,i,i);
    }
    for(ll i=0;i<n;i++)
    {
        ans+=get(1,0,n-1,i,fx[i]);
        upd(1,0,n-1,fx[i],fx[i]);
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'int64_t count_swaps(std::vector<int>)':
shoes.cpp:42:9: error: 'v2' was not declared in this scope
         v2.pb(i);
         ^~
shoes.cpp:42:9: note: suggested alternative: 'v'
         v2.pb(i);
         ^~
         v
shoes.cpp:46:9: error: 'v1' was not declared in this scope
         v1.pb(i);
         ^~
shoes.cpp:46:9: note: suggested alternative: 'v'
         v1.pb(i);
         ^~
         v
shoes.cpp:53:16: error: 'v1' was not declared in this scope
             if(v1[i][j]>v2[i][j]){ans++;swap(v1[i][j],v2[i][j]);}
                ^~
shoes.cpp:53:16: note: suggested alternative: 'v'
             if(v1[i][j]>v2[i][j]){ans++;swap(v1[i][j],v2[i][j]);}
                ^~
                v
shoes.cpp:53:25: error: 'v2' was not declared in this scope
             if(v1[i][j]>v2[i][j]){ans++;swap(v1[i][j],v2[i][j]);}
                         ^~
shoes.cpp:53:25: note: suggested alternative: 'v'
             if(v1[i][j]>v2[i][j]){ans++;swap(v1[i][j],v2[i][j]);}
                         ^~
                         v
shoes.cpp:54:16: error: 'v1' was not declared in this scope
             fx[v1[i][j]]=v2[i+n][j];
                ^~
shoes.cpp:54:16: note: suggested alternative: 'v'
             fx[v1[i][j]]=v2[i+n][j];
                ^~
                v
shoes.cpp:54:26: error: 'v2' was not declared in this scope
             fx[v1[i][j]]=v2[i+n][j];
                          ^~
shoes.cpp:54:26: note: suggested alternative: 'v'
             fx[v1[i][j]]=v2[i+n][j];
                          ^~
                          v