Submission #60218

# Submission time Handle Problem Language Result Execution time Memory
60218 2018-07-23T21:06:17 Z reality Towns (IOI15_towns) C++17
0 / 100
24 ms 820 KB
#include "towns.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int N = 256;

int D[N][N];

int hubDistance(int n, int sub) {
	for (int i = 0;i < n;++i)
		for (int j = 0;j < i;++j)
			D[i][j] = D[j][i] = getDistance(i,j);
	int mx = 0;
	for (int i = 0;i < n;++i)
		for (int j = 0;j < n;++j)
			smax(mx,D[i][j]);
	int x = max_element(D[1] + 1,D[1] + 1 + n) - D[1];
	int y = max_element(D[x] + 1,D[x] + 1 + n) - D[x];
	assert(D[x][y] == mx);
	vi s;
	pii ans = mp((int)(2e9),0);
	for (int x = 0;x < n;++x)
		for (int y = 0;y < x;++y)
			if (D[x][y] == mx) {
				map < int , int > M;
				for (int k = 0;k < n;++k)
					if (k != x && k != y)
						++M[(D[x][y] - (D[x][k] - D[y][k])) / 2];
				int ok = 1;
				for (auto it : M)
					ok &= it.se <= (n / 2),s.pb(it.fi);
				s.pb(D[x][y]);
				sort(all(s));
				s.resize(unique(all(s)) - s.begin());
				for (auto it : s)
					smin(ans,mp(max(D[x][y] - it,it),ok));
			}
	return ans.fi * (1 - 2 * ans.se);
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:30:45: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
  int x = max_element(D[1] + 1,D[1] + 1 + n) - D[1];
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
towns.cpp:31:45: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
  int y = max_element(D[x] + 1,D[x] + 1 + n) - D[x];
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
towns.cpp:35:11: warning: declaration of 'x' shadows a previous local [-Wshadow]
  for (int x = 0;x < n;++x)
           ^
towns.cpp:30:6: note: shadowed declaration is here
  int x = max_element(D[1] + 1,D[1] + 1 + n) - D[1];
      ^
towns.cpp:36:12: warning: declaration of 'y' shadows a previous local [-Wshadow]
   for (int y = 0;y < x;++y)
            ^
towns.cpp:31:6: note: shadowed declaration is here
  int y = max_element(D[x] + 1,D[x] + 1 + n) - D[x];
      ^
towns.cpp:22:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int n, int sub) {
                            ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 820 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 820 KB Output isn't correct
2 Halted 0 ms 0 KB -