Submission #485746

#TimeUsernameProblemLanguageResultExecution timeMemory
485746qwerasdfzxclArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> pos[100100]; struct Seg{ int tree[200200], sz; void init(int n) {sz = n;} void update(int p){for(tree[p+=sz]++;p>1;p>>=1) tree[p>>1]++;} int query(int l, int r){ int ret = 0; for (l+=sz, r+=sz;l<r;l>>=1, r>>=1){ if (l&1) ret += tree[l++]; if (r&1) ret += tree[--r]; } return ret; } }tree; inline myabs(int x){ if (x<0) return -x; return x; } long long count_swaps(std::vector<int> s) { int n = s.size()/2; for (int i=n*2-1;i>=0;i--) if (s[i]<0) pos[-s[i]].push_back(i); ll ret = 0; vector<int> vec(s.size(), -1); int cnt = 0; for (int i=0;i<n*2;i++) if (s[i]>0){ vec[pos[s[i]].back()] = cnt++; pos[s[i]].pop_back(); } tree.init(n+1); cnt = 0; for (int i=0;i<n*2;i++){ if (vec[i]==-1) cnt++; else{ ret += myabs(cnt-vec[i]) + tree.query(vec[i]+1, n+1); tree.update(vec[i]); } } return ret; }

Compilation message (stderr)

shoes.cpp:21:8: error: ISO C++ forbids declaration of 'myabs' with no type [-fpermissive]
   21 | inline myabs(int x){
      |        ^~~~~