Submission #912825

# Submission time Handle Problem Language Result Execution time Memory
912825 2024-01-20T02:17:08 Z Muhammad_Aneeq Ideal city (IOI12_city) C++17
0 / 100
7 ms 2908 KB
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int const MAXN=1e5+10;
vector<int>nei[MAXN]={};
int mod=1e9;
int DistanceSum(int N, int X[], int Y[])
{
	int ans=0;
	map<int,vector<int>>d;
	for (int i=0;i<N;i++)
		d[X[i]].push_back(Y[i]);
	bool subtask_3=1;
	for (auto& i:d)
	{
		sort(begin(i.second),end(i.second));
		if (i.second.size()!=i.second.back()-i.second[0]+1)
		{
			subtask_3=0;
			break;
		}
	}
	if (subtask_3)
	{
		sort(Y,Y+N);
		sort(X,X+N);
		int ans=0;
		long long szx=0,sux=0,szy=0,suy=0;
		for (int i=0;i<N;i++)
		{
			long long g=1ll*Y[i]*szy-suy;
			g%=mod;
			ans=(ans+g)%mod;
			g=1ll*X[i]*szx-sux;
			g%=mod;
			ans=(ans+g)%mod;
		}
		return ans;
	}
	return ans;
}

Compilation message

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   19 |   if (i.second.size()!=i.second.back()-i.second[0]+1)
      |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -