Submission #352355

#TimeUsernameProblemLanguageResultExecution timeMemory
352355David_MArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
#include 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, int Ans=0){for(;x;x-=x&(-x))Ans+=f[x];return Ans;}
ll count_swaps(vector<int> s){
	int 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:3:10: error: #include expects "FILENAME" or <FILENAME>
    3 | #include ll long long
      |          ^~
shoes.cpp:5:1: error: 'll' does not name a type
    5 | ll f[300005],b[300005],c[300005],o=1,N;
      | ^~
shoes.cpp: In function 'void upd(int)':
shoes.cpp:6:27: error: 'N' was not declared in this scope
    6 | void upd(int x){for(;x<=2*N;x+=x&(-x))f[x]+=o;}
      |                           ^
shoes.cpp:6:39: error: 'f' was not declared in this scope
    6 | void upd(int x){for(;x<=2*N;x+=x&(-x))f[x]+=o;}
      |                                       ^
shoes.cpp:6:45: error: 'o' was not declared in this scope
    6 | void upd(int x){for(;x<=2*N;x+=x&(-x))f[x]+=o;}
      |                                             ^
shoes.cpp: At global scope:
shoes.cpp:7:1: error: 'll' does not name a type
    7 | ll get(int x, int Ans=0){for(;x;x-=x&(-x))Ans+=f[x];return Ans;}
      | ^~
shoes.cpp:8:1: error: 'll' does not name a type
    8 | ll count_swaps(vector<int> s){
      | ^~