Submission #534794

#TimeUsernameProblemLanguageResultExecution timeMemory
534794makanhuliaArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double db;
#define pairll pair<ll,ll>
#define lpairll pair<pairll,ll>
 
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define repp(i,a,b) for(ll i = (a); i <= (b); i++)
#define repm(i, a, b) for (ll i = (a); i >= (b); i--)
#define repz(i, a, b) for (ll i = (a); i < (b); i++)
 
const ll MOD = 1e9+7, N = 2e5 + 5, M = 4e5+5, C = 1e5;

ll tc = 1, n, m=0, ar[N], tree[M];
string s, ye = "YES", no = "NO";
queue<ll> loc[N];

void fastt(){ 
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}

void input(){
  
}

void solve(){
  
}

ll query(ll nw, ll l, ll r, ll x, ll y){
  if(l > y || r < x) return 0;
  if(l >= x && r <= y) return tree[nw];
  ll mid = (l+r)/2;
  return query(nw*2,l,mid,x,y) + query(nw*2+1,mid+1,r,x,y);
}

void upd(ll nw, ll l, ll r, ll idx){
  if(l == r){
    tree[nw] = 1;
    return;
  }
  ll mid = (l+r)/2;
  if (idx <= mid) upd(nw*2,l,mid,idx);
  else upd (nw*2+1,mid+1,r,idx);
  tree[nw] = tree[nw*2] + tree[nw*2+1]; 
}

ll count_swaps(vector<ll> v){
  vector<ll> t;
  ll n = v.size();
  t.pb(0);
  for (auto i : v) t.pb(i);
  v = t;
  repz(i,1,v.size()){
    loc[v[i]+C].push(i);
  }
  ll ans = 0;
  memset(tree,0,sizeof(tree));
  repz(i,1,v.size()){
    if(loc[v[i]+C].size() <= 0) continue;
    ll ed = (v[i] > 0), nx;
    nx = loc[C-v[i]].front();
    loc[C-v[i]].pop();
    loc[C+v[i]].pop();
    ed += nx-i-1;
    ed -= query(1,1,n,i+1,nx-1);
    upd(1,1,n,i);
  }

  return ans;
}

// int main(){
//   // freopen("input.txt", "r", stdin);
//   //freopen("output.txt", "w", stdout);
//   fastt();
//   //cin >> tc;
//   while(tc--){
//     input();
//     solve();
//   }
// }

/*

*/

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<long long int>)':
shoes.cpp:15:42: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define repz(i, a, b) for (ll i = (a); i < (b); i++)
      |                                          ^
shoes.cpp:61:3: note: in expansion of macro 'repz'
   61 |   repz(i,1,v.size()){
      |   ^~~~
shoes.cpp:15:42: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define repz(i, a, b) for (ll i = (a); i < (b); i++)
      |                                          ^
shoes.cpp:66:3: note: in expansion of macro 'repz'
   66 |   repz(i,1,v.size()){
      |   ^~~~
/usr/bin/ld: /tmp/cc0S7Muf.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status