#include #include #include #include #include using namespace std; int partition(float arr[], int arrId[], int start, int end) { float pivot = arr[start]; int count = 0; for (int i = start + 1; i <= end; i++) { if (arr[i] <= pivot) count++; } int pivotIndex = start + count; swap(arr[pivotIndex], arr[start]); swap(arrId[pivotIndex], arrId[start]); // Sorting left and right parts of the pivot element int i = start, j = end; while (i < pivotIndex && j > pivotIndex) { while (arr[i] > pivot) { i++; } while (arr[j] <= pivot) { j--; } if (i < pivotIndex && j > pivotIndex) { swap(arr[i], arr[j]); swap(arrId[i++], arrId[j--]); } } return pivotIndex; } void quickSort(float arr[], int arrId[], int start, int end) { if (start >= end) return; int p = partition(arr, arrId, start, end); quickSort(arr, arrId, start, p - 1); quickSort(arr, arrId, p + 1, end); } int main() { ifstream inp; inp.open("mars.in"); int n,r,x,y, xMax=0, yMax = 0, max; inp>>n>>r; int** pp = new int*[n]; for (int i = 0; i < n; ++i) { pp[i] = new int[2]; inp>>x>>y; pp[i][0] = x; if (x>xMax){ xMax = x; } pp[i][1] = y; if (y>yMax){ yMax = y; } } max = xMax; if (yMax>max) { max = yMax; } int G = max / r; if (G>14000) { G /= 2; } if (G>6000) { G /= 2; } if (G>2500) { G /= 2; } if (r>350) { G /= 2; } int** c = new int*[G]; int** p = new int*[G]; for (int i = 0; i < G; ++i) { c[i] = new int[G]; p[i] = new int[G]; for (int j = 0; j < G; ++j) { c[i][j] = 0; } } for (int i = 0; i < n; ++i) { x = pp[i][0]; y = pp[i][1]; x--; y--; x = x*G/max; y = y*G/max; p[x][y] = i+1; c[x][y]++; } inp.close(); //cout<<1<= b) { //cout<<2<<" "<0) { k++; } } } if (k < 1) { out<<1<0) { out<