Submission #387029

#TimeUsernameProblemLanguageResultExecution timeMemory
387029Koosha_mvIdeal city (IOI12_city)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl; #define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl; #define Get(x,y) scanf("%I64d%I64d",&x,&y); #define is_bit(x,y) (x%(1<<(y+1))>=(1<<y)) #define eror(x) cout<<#x<<'='<<(x)<<endl; #define f_(i,a,b) for(int i=a;i>=b;i--) #define Gett(x,y) scanf("%d%d",&x,&y); #define f(i,a,b) for(int i=a;i<b;i++) #define get(x) scanf("%I64d",&x); #define gett(x) scanf("%d",&x); #define maxm(a,b) a=max(a,b); #define minm(a,b) a=min(a,b); #define Add(x,y) x=(x+y)%mod #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define F first #define S second #include <stdio.h> #include <stdlib.h> #include <assert.h> #define inbuf_len 1 << 16 #define outbuf_len 1 << 16 const int N=1e5+9; int n; ll ans; pair<int,int> a[N]; map<pair<int,int>,int> mark,cnt; ll e(int x){ return 1ll*x*(x-1)/2; } void swap(){ f(i,0,n) swap(a[i].F,a[i].S); } void solve(){ mark.clear(); sort(a,a+n); f(i,0,n){ int x=a[i].F,y=a[i].S; mark[mp(x,y)]=mark[mp(x,y-1)]+1; if(a[i+1].F!=x || a[i+1].S!=y+1){ cnt[mp(x,y)]=cnt[mp(x-1,y)]; ans+=e(n); ans-=e(cnt[mp(x,y)])+e(n-cnt[mp(x,y)]-mark[mp(x,y)]); cnt[mp(x,y)]+=mark[mp(x,y)]; } for(int j=i-1;0<=j && a[j].F==a[j+1].F && a[j].S+1==a[j+1].S;j--) cnt[mp(a[j].F,a[j].S)]=cnt[mp(x,y)]; } } int DistanceSum(int n, int *X, int *Y){ solve(); swap(); solve(); cout<<ans-(e(n)); } int main() { int tmp; /* Set input and output buffering */ char *inbuf, *outbuf; inbuf = (char*) malloc(inbuf_len * sizeof(char)); outbuf = (char*) malloc(outbuf_len * sizeof(char)); tmp = setvbuf(stdin, inbuf, _IOFBF, inbuf_len); assert(tmp == 0); tmp = setvbuf(stdout, outbuf, _IOFBF, outbuf_len); assert(tmp == 0); int i; tmp = scanf("%d", &n); assert(tmp == 1); int *sq_x, *sq_y; sq_x = (int*) malloc(n * sizeof(int)); sq_y = (int*) malloc(n * sizeof(int)); for (i = 0; i < n; i++) { tmp = scanf("%d %d", &sq_x[i], &sq_y[i]); a[i]=mp(sq_x[i],sq_y[i]); assert(tmp == 2); } int ds = DistanceSum(n, sq_x, sq_y); printf("%d\n", ds); return 0; }

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:64:1: warning: no return statement in function returning non-void [-Wreturn-type]
   64 | }
      | ^
/tmp/ccEr1QJa.o: In function `main':
city.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccSyiqVp.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status