Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; int n; int a[100010]; void output() { for (int i = 0; i < n; i++) printf("%d ", a[i]); puts(""); } int check() { for (int i = 0; i < n; i++) if (a[a[i] - 1] != n - i) return 0; return 1; } int main() { cin >> n; for (int i = 0; i < n / 2; i += 2) a[i] = i + ...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String args[]) throws IOException { InputReader in=new InputReader(System.in); PrintWriter out=new PrintWriter(System.out); int N=in.readInt(); int A[]=new int[N+1]; ...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; long p[100001]; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); long n; cin >> n; if (n % 4 == 2 || n % 4 == 3) cout << "-1"; else { if (n % 2) p[n / 2 + 1] = n / 2 + 1; for (int i = 1; i < n / 2; i += 2) { p[i] = i + 1; p[i ...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.util.*; import java.io.*; public class Round176A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); if(n%4==2 || n%4==3){ System.out.println(-1); return; } if(n%4==0){ int[] p = new int[n+...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if (n % 4 > 1) { cout << "-1\n"; return 0; } int p[n]; if (n % 4 == 1) { p[n / 2] = (n + 1) / 2; } if (n != 1) { p[0] = 2; p[1] = n; p[n - 2] = 1; p[n - 1] = n...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
n=int(input()) if n==1: print (1) exit() if n%4>1: print (-1) exit() ans=[-1]*n left=n start=n-2 nums=1 nume=n while left>=4: ans[start]=nums ans[nums-1]=nums+1 ans[nums]=nume ans[nume-1]=nume-1 start-=2 nums+=2 nume-=2 left-=4 # print (ans) if left==1: ans[start+1]=start+2 print (*ans)
PYTHON3
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; int a[100001]; int main() { int n; cin >> n; if (n % 4 == 2 || n % 4 == 3) { cout << -1 << endl; return 0; } int i; if (n % 2 == 1) a[(n + 1) / 2] = (n + 1) / 2; for (i = 1; i <= n / 2;) { a[i] = i + 1; a[i + 1] = n - i + 1; a[n - i + 1] = ...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; // Lucky Permutation // 2013/03/23 public class P286A{ Scanner sc=new Scanner(System.in); int n; void run(){ n=sc.nextInt(); so...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top * @author PM */ public class Main { ...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.util.Scanner; public class CodeforcesRound176C { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner kde= new Scanner(System.in); int n=kde.nextInt(); if((n%4==2)||(n%4==3)) { System.out.println(-1); return; } int[] m= ne...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; inline bool xdy(double x, double y) { return x > y + 1e-9; } inline bool xddy(double x, double y) { return x > y - 1e-9; } inline bool xcy(double x, double y) { return x < y - 1e-9; } inline bool xcdy(double x, double y) { return x < y + 1e-9; } const long long int mod = 10...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 4 > 1) { cout << -1; return 0; } int m = n / 4, perm[100001]; for (int i = 0; i < m; i++) { int a, b, c, d; a = 2 * i + 1; b = 2 * i + 2; c = n - 2 * i; d = n - 2 * i - 1; perm[a] = b; per...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { // Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in), 16000)); InputStream inputStream = System.in; OutputStream outputStream = System.out; ...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.io.PrintWriter; import java.util.Scanner; public class C { public static void main(String [] args){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); if(n%4==1 || n%4==0){ int a [] = new int[n+1]; for(int i = 1 ; i <= n/2 ; i+=2 ){ ...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.LinkedList; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solut...
JAVA
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; int n; deque<int> ans; bool used[100500]; int add(int i, int n) { if (n % 2 == 0) { if (i >= n / 2) i = n - i - 1; return i / 2; } if (i > n / 2) i = n - i - 1; return i / 2; } int main() { cin >> n; if (n == 1) { cout << 1; return 0; } else if...
CPP
287_C. Lucky Permutation
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≀ pi ≀ n). A lucky permutation is such permutation p, that any integer i (1 ≀ i ≀ n) meets this condition ppi = n - i + 1. You have integer n. Find some lucky permutation p of size n. Input T...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int a[maxn]; int main() { int n; cin >> n; if (n % 4 == 2 || n % 4 == 3) cout << -1 << endl; else if (n % 4 == 0) { for (int i = 1; i <= (n / 2); i++) { if ((i % 2) == 1) a[i] = i + 1; else a[i] = n - i ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n,k = map(int,input().split()) if n*(n-1) <= k*2: print('no solution') else: for i in range(n): print(0,i)
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
# -*- coding: utf-8 -*- """ Created on Sat Jul 06 18:16:44 2013 @author: workshop """ from __future__ import division; from bisect import *; from fractions import Fraction; import sys; from math import *; from fractions import *; import io; import re; INF = 987654321987654321987654321; def readint(delimiter=' ') : ...
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ //package Practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author Rohan */ public class Main { /** * @param args the command line arguments ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
''' Created on 2013-5-27 @author: zhxfl ''' a, b = map(int,raw_input().split()); n = a * (a - 1) / 2; if b >= n: print 'no solution' else: for i in range(a): print 0, i;
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.math.BigInteger; import java.util.*; import java.text.*; public class cf312C { static BufferedReader br; static Scanner sc; static PrintWriter out; public static ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (!a) return b; return GCD(b % a, a); } vector<int> x(4000); vector<int> y(4000); void D(double x, double y, double x1, double y1) { double d = (x - x1) * (x - x1) + (y - y1) * (y - y1); cout << sqrt(d) << "\n"; } int main() { int n, k; ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int i, n, k; cin >> n >> k; if (n * (n - 1) / 2 <= k) { puts("no solution"); return 0; } for (i = 1; i <= n; i++) { printf("0 %d\n", i); } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long n, k; cin >> n >> k; long kc = 2001; if (k >= n * (n - 1) / 2) { cout << "no solution"; return 0; } long sum = 0; long ax[2005], ay[2005]; for (int i = 1; i <= n; i++) { sum += kc; ax[i] = 0; ay[i] = sum; cout << 0 <...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; template <class T> T gmin(T u, T v) { return (u < v) ? u : v; } template <class T> T gmax(T u, T v) { return (u > v) ? u : v; } template <class T> T gcd(T u, T v) { if (v == 0) return u; return (u % v == 0) ? v : gcd(v, u % v); } int main() { long long n, m, tmp; ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; long long distance(long long x1, long long y1, long long x2, long long y2) { return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); } int main() { long long n, k, d, x, y, tot = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { t...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); if ((n * (n - 1)) / 2 <= k) { printf("no solution\n"); return 0; } for (int i = 0; i < (int)n; i++) printf("%d %d\n", 0, i); return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.*; public class Pair{ public static void main(String[] args){ Scanner reader = new Scanner(System.in); int n = reader.nextInt(); int k = reader.nextInt(); Point[] p = new Point[n]; Point dir = new Point(1,2001); p[0] = new Point(0,0); for(int i = 1; i < n; i++) p[i] = p[i-1].add(dir)...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; if (n * (n - 1) / 2 <= k) { cout << "no solution\n"; return 0; } for (int i = 1; i <= n; i++) { cout << 1 << " " << i + i << "\n"; } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (((n) * (n - 1)) / 2 > k) { for (int i = 0; i < n; i++) cout << "0 " << i << endl; } else { cout << "no solution" << endl; } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if ((n - 1) * n / 2 <= k) { cout << "no solution" << endl; } else { int tot = 0; int i, j; for (i = 0; i <= 1e9; i++) for (j = 0; j <= 1e9; j++) { if (tot < n) { cout << i << " " << j << e...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (k >= (n * (n - 1)) / 2) cout << "no solution" << endl; else { for (int i = 0; i < n; i++) cout << '0' << ' ' << i << endl; } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n,k=list(map(int,input().split())) if (n*n-n)//2<=k: print("no solution") else: x=0 y=0 store=[] count=0 store.append(str(x)+' '+str(y)) while len(store)<n: y+=1 store.append(str(x)+' '+str(y)) for j in store: print(j)
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; if (((n * (n - 1)) >> 1) <= k) { cout << "no solution"; return 0; } for (int i = 0; i < n; ++i) { cout << i << ' ' << 1000000000 - i * 3000 << endl; } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; while (cin >> n >> k) { if (n * (n - 1) / 2 <= k) { cout << "no solution" << endl; } else { for (int i = 0; i < n; i++) { cout << 0 << ' ' << i << endl; } } } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; if (k >= n * (n - 1) / 2) { cout << "no solution\n"; } else { for (long long int i = 0; i < n; i++) { cout << "0 " << i << endl; } } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; long long Min(long long i, long long j) { return i < j ? i : j; } long long Max(long long i, long long j) { return i > j ? i : j; } int main() { long long a, b, c, d, e, i, j, k, l, m, n; while (cin >> n >> k) { if (k >= (n * (n - 1)) / 2) cout << "no solution...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; if (n * (n - 1) / 2 <= k) { cout << "no solution" << '\n'; return 0; } else { for (int i = 1; i <= n; i++) { cout << "1 " << i + 1 << endl; } } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class CF { public static void main(String[] args) throws IOException { InputStream inpu...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int y, k, n, x, i; scanf("%d%d", &n, &k); n--; x = (n * (n + 1)) / 2; if (x > k) { for (i = 1; i <= n + 1; i++) printf("0 %d\n", i); } else printf("no solution\n"); }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.Arrays; import java.util.Locale; import java.util.Scanner; public class NearestPairSolver { private int n; private int k; public static void main(String[] args) { NearestPairSolver solver = new NearestPairSolver(); solver.readData(); int[] solution = solver.solve...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> int main() { int n, K; scanf("%d%d", &n, &K); int tot = (n * n - n) / 2; if (tot <= K) { printf("no solution\n"); return 0; } int x = 0, y = 0; for (int i = 0; i < n; i++) { printf("%d %d\n", 0, y); y += 2; } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n, k = [int(x) for x in raw_input().split()] if k >= n*(n-1)/2: print 'no solution' else: while n: print 1, n n -= 1
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector<pair<int, int>> v; int now = 1; for (int i = 1; i <= n - 1; ++i) { v.emplace_back(1, now); now += 2; } v.emplace_back(1, now); int tot = 0; for (int i = 1; i <= n; ++i...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class TheClosestPair { public static void main(String[] args) { MyScanner sc = new MyScanner(); int N = sc.nextInt(); int K = sc.nextInt(); ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.*; import java.math.BigInteger; import java.util.StringTokenizer; /** * Created by Leonti on 2016-03-12. */ public class C { public static void main(String[] args) { InputReader inputReader = new InputReader(System.in); PrintWriter printWriter = new PrintWriter(System.out, true); ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
def calk(n): return n*(n-1)/2 n,k = map(int,raw_input().split()) if calk(n) > k: for i in range(n): print 0,i else : print "no solution"
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class my_class { public static void main(String[] args) { Scanner ololo = new Scanner(System.in); int n = ololo.nextInt(), k = ololo.nextInt(); if((n*(n - 1) /2) <= k){ System.out.println("no solution"); }else{ for(...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOEx...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, l, m, n, x, y, z, r, ans = 0, mn = INT_MAX, mx = INT_MIN, res = 0; cin >> n >> k; if (k * 2 >= n * (n - 1)) cout << "no solution"; else { for (i = 0; i < n; ++i) { cout << 0 << " " << n + 1 ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> int main() { long long p, n; int i = 0, j = 2; scanf("%I64d %I64d", &n, &p); if (((n - 1) * n) / 2 <= p) printf("no solution\n"); else while (n--) { printf("%d %d\n", i, j); j += 2; } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { private void solve() throws IOException { int n = ni(); int k = ni(); if (n * (n - 1) / 2 <= k) { prln("no solution"); return; } ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; long long power(long long b, long long e, long long m) { if (e == 0) return 1; if (e % 2) return b * power(b * b % m, (e - 1) / 2, m) % m; else return power(b * b % m, e / 2, m); } long long power(long long b, long long e) { if ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; int N, K; void Read() { cin >> N >> K; } void Print() { if (K >= N * (N - 1) / 2) { cout << "no solution\n"; return; } for (int i = 1; i <= N; ++i) cout << "0 " << i << "\n"; } int main() { Read(); Print(); return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
s=input().split() n=int(s[0]) k=int(s[1]) ans=[] a=0 for i in range(n): for j in range(i+1,n): a+=1 if(a<=k): print("no solution") else: for i in range(-10**9,-10**9+n): print("0 "+str(i))
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import sys n, k = [int(el) for el in sys.stdin.readline().split()] if (n - 1) * n / 2 <= k: print "no solution" else: for i in xrange(n): print 0, i
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.TreeSet; public class ProblemA { class Point implements Comparable<Point>{ int x; int y; public Point(int a, int b) { x = a; y = b; } @Override pu...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the to...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int maxK = ((n - 1) * n) / 2; if (maxK <= k) { cout << "no solution" << endl; } else { for (int i = 0; i < n; i++) { cout << "0 " << i << endl; } } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, j, tot = 0; scanf("%d%d", &n, &k); if (n * (n - 1) / 2 > k) { for (i = 1; i <= n && tot < n; i++) { for (j = i + 1; j <= n && tot < n; j++, tot++) { printf("%d %d\n", i, j); } } } else puts("no solution"); ...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.*; import java.util.*; public class TheClosestPair { public TheClosestPair(Scanner in) { int n, k; int steps; int i; n = in.nextInt(); k = in.nextInt(); steps = (n-1)*(n)/2; if (steps <= k) System.out.printf("no solution%n"); else ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d", &n); scanf("%d", &k); int tComplexity = n * (n - 1) / 2; if (tComplexity > k) { for (int i = 0; i < n; i++) { printf("%d %d\n", 0, i); } } else printf("%s\n", "no solution"); return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n, k = map(int,raw_input().split()) tot = n*(n-1)/2 if tot <= k: print "no solution" else: for i in range(n): print 13,i
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; t = 1; while (t--) { long long n, k, i; cin >> n >> k; if (k >= (n * (n - 1)) / 2) cout << "no solution"; else { long long a[n], b[n]; for (i = 0; i < n; i...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); if (k>=n*(n-1)/2) { System.out.println("no solution"); in.close(); return; } for (int i = 0; i < n; ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d%d", &n, &k); if (n * (n - 1) / 2 > k) { for (int i = 0; i < n; i++) printf("0 %d\n", i); } else printf("no solution"); return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k; int main() { cin >> n >> k; if (((n - 1) * n) / 2 <= k) { cout << "no solution" << endl; return 0; } for (int i = 0; i < n; i++) cout << 0 << " " << i << endl; return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> int main() { int n, k; while (scanf("%d%d", &n, &k) != EOF) { if (k >= n * (n - 1) / 2) { printf("no solution\n"); } else { for (int i = 0; i < n; i++) { printf("0 %d\n", i); } } } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.*; public class cf311a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int max = (n*n-n)/2; if(max <= k) System.out.println("no solution"); else for(int i=0; i<n; i++) System.out.println(0+...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#!/usr/bin/python n, k = map(int, raw_input().split()) if n*(n-1)/2 <= k: print "no solution" else: for y in xrange(n): print 0, y
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (n * (n - 1) / 2 <= k) { cout << "no solution" << endl; } else { for (int i = 0; i < n; i++) { cout << "0 " << i << endl; } } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (n * (n - 1) / 2 <= k) cout << "no solution"; else for (int i = 1; i <= n; i++) cout << "0 " << i << '\n'; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.*; import java.util.*; import java.util.Map.Entry; public class C { void run() throws IOException { int n = ni(), k = ni(); if ((n * (n - 1)) / 2 <= k) { pw.println("no solution"); } else { for (int i = 1; i <= n; i++) { pw.println(0 + " " + i); } } // for (int i = 2; i <= 100; ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class Solve implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); if (n * 1LL * (n - 1) / 2 <= k) printf("no solution\n"); else { for (int i = 0; i < n; i++) printf("%d %d\n", 0, i); } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i; cin >> n >> k; if (k >= n * (n - 1) / 2) { cout << "no solution" << endl; return 0; } for (i = 1; i <= n; i++) cout << "0 " << i << endl; return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n,k=map(int, input().split()) if(n*(n-1)//2 <=k): print('no solution') else: for i in range(n): print(0,i)
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.PrintWriter; import java.util.Scanner; public class C185D2C { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(), k = in.nextInt(); if (k >= n*(n-1) / 2) { out....
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.*; import java.util.*; public class C { public static void main(String[] args){ FastScanner sc = new FastScanner(); int n = sc.nextInt(); int k = sc.nextInt(); if(((n * (n - 1)) / 2) <= k) { System.out.println("no solution"); } else { for(int i = 0; i < n; i++) { ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m = (long long)(1e9 + 7)) { return (n % m + m) % m; } inline long long gcd(long long a, long long b) { return (b == 0LL) ? a : gcd(b, a % b); } inline long long modPow(long long a, long long b, long lon...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
from Queue import * # Queue, LifoQueue, PriorityQueue from bisect import * #bisect, insort from datetime import * from collections import * #deque, Counter,OrderedDict,defaultdict import calendar import heapq import math import copy import itertools def solver(): n,k = map(int, raw_input().split()) if k ...
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
x = raw_input().split() n = int(x[0]) k = int(x[1]) tot = n*(n-1)/2 if tot <= k: print "no solution" else: for i in range(n): print "0", i
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); sc = new StringTokenizer(br.readLi...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); int sum = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) sum++; Strin...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
__author__ = 'liuchang' import sys n , k = map(int , sys.stdin.readline().split(' ')) if n * (n -1 ) / 2 <= k: print "no solution" else: for i in range(n): print "%d %d" % ( 0, i )
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n, k = [int(i) for i in raw_input().strip().split()] if k >= (n)*(n-1)/2: print "no solution" else: print "0 0" x = 0 y = 0 k = n - 1 for i in range(2, n+1): x += 1 y += k k -= 1 print x, y
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
N, K = [int(x) for x in raw_input().split()] if K>=N*(N-1)/2: print 'no solution' else: for i in xrange(N): print '0 %d'%i
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n,k = map(int, raw_input().split(' ')) if k>=(n-1)*n/2: print "no solution" else: a=0 b=0 for i in range(n): print a,b b+=1
PYTHON
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import sys input=sys.stdin.readline from collections import defaultdict as dc from collections import Counter from bisect import bisect_right, bisect_left import math from operator import itemgetter from heapq import heapify, heappop, heappush from queue import PriorityQueue as pq n,k=map(int,input().split()) if k>=n*(...
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; long long int modpow(long long int a, long long int n, long long int temp) { long long int res = 1; while (n > 0) { res = (res * res) % temp; if (n & 1) res = (res * a) % temp; n /= 2; } return res; } long long int gcd(long long int a, long long int b) {...
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
n,k = map(int,input().split()) if n*(n-1) <= k*2: print('no solution') else: x = 11 for i in range(n-1): print(1,x) x+=3 print(1,x-5)
PYTHON3
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.*; import java.io.*; public class a { static long mod = 1000000007; public static void main(String[] args) throws IOException { //Scanner input = new Scanner(new File("input.txt")); //PrintWriter out = new PrintWriter(new File("output.txt")); input.init(System.in); PrintWriter out = ne...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.Scanner; public class c { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int cur=0; for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) cur++; if (cur<=k) System.out.print...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> int main() { int n, k, i; scanf("%d %d", &n, &k); if (k >= n * (n - 1) / 2) { puts("no solution"); } else { for (i = 0; i < n; i++) printf("0 %d\n", i); } return 0; }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (n * (n - 1) / 2 > k) { for (int i = 0; i < n; i++) { printf("%d %d\n", 0, i); } } else { cout << "no solution"; } }
CPP
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.*; import java.math.*; public class Main { static Input in; static Output out; static final boolean OJ = System.getProperty("ONLINE_JUDGE") != null; public static void main(String[] args) throws IOException { in = new Input(OJ ? System.in : new FileInputStream("in.txt")); ...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { long n = sc.nextLong(); long k=sc.nextLong(); long max=n*(n...
JAVA
312_C. The Closest Pair
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given n points in the plane, find a pair of points between...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { static StringTokenizer st; static BufferedReader in; static Pri...
JAVA