using Microsoft.Win32.SafeHandles; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Xml.Schema; public static class Ex { public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); } public static void yesno(this bool b) => Console.WriteLine(b ? "yes" : "no"); public static void YesNo(this bool b) => Console.WriteLine(b ? "Yes" : "No"); public static void YESNO(this bool b) => Console.WriteLine(b ? "YES" : "NO"); //[MethodImpl(MethodImplOptions.AggressiveInlining)] //public static bool Chmax(ref this T a, T b) where T : struct, IComparable //{ // if (b.CompareTo(a) > 0) { a = b; return true; } // else return false; //} //[MethodImpl(MethodImplOptions.AggressiveInlining)] //public static bool Chmin(ref this T a, T b) where T : struct, IComparable //{ // if (b.CompareTo(a) < 0) { a = b; return true; } // else return false; //} public static List FastSort(this List s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); } public static int PopCount(this uint bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff)); } } partial class Program { [MethodImpl(MethodImplOptions.AggressiveInlining)] string GetStr() { return Console.ReadLine().Trim(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] char GetChar() { return Console.ReadLine().Trim()[0]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] int GetInt() { return int.Parse(Console.ReadLine().Trim()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] long GetLong() { return long.Parse(Console.ReadLine().Trim()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } [MethodImpl(MethodImplOptions.AggressiveInlining)] string[][] GetStrArray(int N) { var res = new string[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' '); return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] int[][] GetIntArray(int N) { var res = new int[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] long[][] GetLongArray(int N) { var res = new long[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] double[][] GetDoubleArray(int N) { var res = new double[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] char[][] GetGrid(int H) { var res = new char[H][]; for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray(); return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] T[] CreateArray(int N, T value) { var res = new T[N]; for (int i = 0; i < N; i++) res[i] = value; return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] T[][] CreateArray(int H, int W, T value) { var res = new T[H][]; for (int i = 0; i < H; i++) { res[i] = new T[W]; for (int j = 0; j < W; j++) res[i][j] = value; } return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] T[][][] CreateArray(int H, int W, int R, T value) { var res = new T[H][][]; for (int i = 0; i < H; i++) { res[i] = new T[W][]; for (int j = 0; j < W; j++) { res[i][j] = new T[R]; for (int k = 0; k < R; k++) res[i][j][k] = value; } } return res; } Dictionary> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; dic[a].Add(b); if (isDirected == false) dic[b].Add(a); } return dic; } //Dictionary> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) //{ // var dic = new Dictionary>(); // foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); } // for (int i = 0; i < M; i++) // { // var input = GetIntArray(); // var a = isNode_0indexed ? input[0] : input[0] - 1; // var b = isNode_0indexed ? input[1] : input[1] - 1; // var c = input[2]; // dic[a].Add((b, c)); // if (isDirected == false) dic[b].Add((a, c)); // } // return dic; //} [MethodImpl(MethodImplOptions.AggressiveInlining)] bool eq() => typeof(T).Equals(typeof(U)); [MethodImpl(MethodImplOptions.AggressiveInlining)] T ct(U a) => (T)Convert.ChangeType(a, typeof(T)); [MethodImpl(MethodImplOptions.AggressiveInlining)] T cv(string s) => eq() ? ct(int.Parse(s)) : eq() ? ct(long.Parse(s)) : eq() ? ct(double.Parse(s)) : eq() ? ct(s[0]) : ct(s); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a) => a = cv(GetStr()); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a, out U b) { var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Output(T t) => Console.WriteLine(t); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Output(IList ls) => Console.WriteLine(string.Join(" ", ls)); void Debug(IList> ls) { foreach (var l in ls) foreach (var s in l) Console.WriteLine(s); } void Swap(ref T a, ref T b) { T temp = a; a = b; b = temp; } int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 }; int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 }; long mod = 1000000007; } partial class Program { static void Main() { Console.SetIn(new StreamReader(Console.OpenStandardInput(8192))); Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Program().Solve(); Console.Out.Flush(); Console.Read(); } public void Solve() { int N = GetInt(); var pos = GetLongArray(N); Queue[] queue = new Queue[N]; for (int i = 0; i < N; i++) { queue[i] = new Queue(Enumerable.Range(0, N) .Select((e, index) => new { value = (long)(Math.Pow(pos[e][0] - pos[i][0], 2) + Math.Pow(pos[e][1] - pos[i][1], 2)), index }) .OrderBy(e => e.value) .Skip(1) .Select(e => e.index)); } var set = new HashSet(); int cnt = 0; while(queue[0].Any()) { for (int i = 0; i < N; i++) { if (set.Contains(i)) continue; var peek = queue[i].Peek(); if (queue[peek].Peek() == i) { if (i != 0) { set.Add(i); } else { cnt++; } set.Add(peek); } } for (int i = 0; i < N; i++) { if (set.Contains(i)) continue; while (queue[i].Any() && set.Contains(queue[i].Peek())) queue[i].Dequeue(); } } Output(cnt); } }