Submission #61288

# Submission time Handle Problem Language Result Execution time Memory
61288 2018-07-25T15:05:07 Z zetapi Ideal city (IOI12_city) C++14
0 / 100
9 ms 1972 KB
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e5;
const int mod=1e9;

ll res1,res2,sum[MAX];

int DistanceSum(int N, int *X, int *Y) 
{
	int f=X[0],s=Y[0],f_=X[0],s_=Y[0];
	for(int A=1;A<N;A++)
	{
		f=max(f,X[A]);
		s=max(s,Y[A]);
		f_=min(f_,X[A]);
		s_=min(s_,Y[A]);
	}
	f=f-f_;
	s=s-s_;
	for(ll A=1;A<MAX;A++)
		sum[A]=(sum[A-1]+A)%mod;
	for(ll A=1;A<=s;A++)
	{
		res1+=((A*(A-1))%mod-sum[A-1]+mod)%mod;
		res1%=mod;
	}
	for(ll A=1;A<=f;A++)
	{
		res2+=(((A*(A-1))%mod)-sum[A-1]+mod)%mod;
		res2%=mod;
	}
 	return (int)((res1*f)%mod+(res2*s)%mod)%mod;
}

/*signed main()
{
	ios_base::sync_with_stdio(false);

	int X[]={2,2,3,3,4,4,4,4,5,5,5};
	int Y[]={5,6,3,6,3,4,5,6,3,4,6};
	cout<<DistanceSum(11,X,Y);
	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1972 KB Output isn't correct
2 Halted 0 ms 0 KB -