Submission #352360

#TimeUsernameProblemLanguageResultExecution timeMemory
352360David_MArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #define ll long long using namespace std; ll f[300005],b[300005],c[300005],o=1,N; void upd(int x){for(;x<=2*N;x+=x&(-x))f[x]+=o;} ll get(int x, ll Ans=0){for(;x;x-=x&(-x))Ans+=f[x];return Ans;} long long count_swaps(vector<ll> s){ ll x,ans=0; map<ll, ll> a; N=(int)s.size()/2; for (int i=0; i<2*N; i++){ c[s[i]+2*N]++; if(s[i]<0)s[i]=-(c[s[i]+2*N]<<20)+s[i]; else s[i]=(c[s[i]+2*N]<<20)+s[i]; } for (int i=0; i<2*N; i++)a[abs(s[i])]=i,upd(i+1); o=-1; // for (int i=0; i<2*N; i++)cout<<s[i]<<" "; for (int i=0; i<2*N; i++)if(!b[i+1])x=a[abs(s[i])]+1,b[x]=1,ans+=get(x-1)-get(i)-(s[i]<0),upd(x); return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:17:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   17 |  for (int i=0; i<2*N; i++)a[abs(s[i])]=i,upd(i+1); o=-1;
      |  ^~~
shoes.cpp:17:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   17 |  for (int i=0; i<2*N; i++)a[abs(s[i])]=i,upd(i+1); o=-1;
      |                                                    ^
/tmp/ccoUJRQb.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status