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
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n, x[1001]; cin >> n; if (n <= 3) { cout << "no"; return 0; } for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n - 1; i++) { a = min(x[i], x[i + 1]); b = max(x[i], x[i + 1]); for (int j = 0; j < n - 1; j++) ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
from sys import stdin,stdout input=stdin.readline import math,bisect n=int(input()) l=list(map(int,input().split())) if n<=2: print("no") else: f=0 for i in range(1,n): x1=min(l[i-1],l[i]) x2=max(l[i-1],l[i]) for j in range(i+1,n): x3=min(l[j-1],l[j]) x4=max(l[j-1],l[j]) if x1<x3<x2<x4: f=1 e...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 1; j < n - 1; j++) { a = min(arr[i], arr[i + 1]); b = max(arr[i], arr[i + 1]); c = min(a...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; int x[10000]; int res = 0; int x1, x2, x3, x4; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &x[i]); } for (int i = 1; i <= n - 1; i++) { for (int j = i + 2; j < n; j++) { x1 = min(x[i], x[i + 1]); x2 = m...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Codeforces { private static Print writer; private static Scan reader; static class Scan { private byte[] buf = new byte[1024]; // Buffer of Bytes private int index; private InputStream in; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) a=[*map(int,input().split())] a=list(zip(a,a[1:])) for i in range(n-1): for j in range(n-1): if i==j: continue if min(a[i][0],a[i][1])<min(a[j][0],a[j][1])<max(a[i][0],a[i][1])<max(a[j][0],a[j][1]): print('yes') exit(0) print('no')
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
# Link: http://codeforces.com/problemset/problem/358/A # Love you Atreyee my life. I cannot live without you. n = int(input()) li = list(map(int, input().rstrip().split())) flag = 0 for i in range(0, n - 1): x = min(li[i], li[i + 1]) y = max(li[i], li[i + 1]) for j in range(0, n - 1): a = min(...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n, u, v, r, R, x, m, i, j; pair<int, int> a[1010]; int main() { cin >> n; if (n <= 2) { cout << "no"; return 0; } cin >> u >> v; x = u + v; r = u > v ? 2 * u - x : x - 2 * u; a[++m] = make_pair(x, r); for (n -= 2; n; n--) { cin >> x; u = ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() v = list(map(int, raw_input().split())) w = [(min(v[x], v[x+1]), max(v[x], v[x+1])) for x in range(0, n-1)] for i in range(0, len(w)): for j in range(0, len(w)): if i == j: continue a, b = w[i][0], w[i][1] c, d = w[j][0], w[j][1] if a < c and c < b and (d < a ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) lst = [int(x) for x in input().split()] a = lst[:] a = sorted(a) f = 0 for i in range(n - 1): for j in range(n - 1): if i != j: x1 = [lst[i], lst[i + 1]] x2 = [lst[j], lst[j + 1]] x1 = sorted(x1) x2 = sorted(x2) if x1[0] < x2[0] < ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const double pi = 3.14159265359; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long int b, q, li, mi, a[100005], i, j, k = 0, x = 0, l, m, n, f = 0, x1, x2, x3, x4; cin >> n; for (i ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Dima{ int x; int y; public Dima(int a, int b){ x=a; y=b; } public static void main(String[] args) throws IOException{ BufferedReader br; br = new BufferedReader(new InputStreamReader(Syst...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int prev1 = 0; int smin, smax, min1, max1; bool b2 = false; int check(int k) { if (k > min1 && k < max1) { smin = min1; min1 = k; smax = max1; prev1 = 1; b2 = true; } else if (k < min1) { if (b2 != true) { max1 = smin; smin = k; ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); int[] v = new int[n]; for (int i = 0; i < n; i++) v[i] = in.nextInt(); for (int i = 0; i < n - 1; i++) { for (int j = 0; j < i; j++) ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; public class Main { static class num { int small,big; } public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); if(n==1) { System.out.println("no"); return; } num arr[]=new num[n]; int prev=sc.nextInt(); for(i...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; public class Main { public static void main(String[] args) { InputStream inputStream = System....
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) a = [int(y) for y in input().split()] flag = 0 for i in range(len(a)-2): for j in range(i, 0, -1): r = min(a[j], a[j-1]) s = max(a[j], a[j-1]) if (a[i+2] > r and a[i+2] < s) and (a[i+1] > s or a[i+1] < r): flag += 1 break elif (a[i+1] > r and ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) arr = list(map(int,input().split())) for i in range(n-1): for j in range(i+1,n-1): a = min(arr[i], arr[i+1]) b = max(arr[i], arr[i+1]) c = min(arr[j], arr[j+1]) d = max(arr[j], arr[j+1]) if a < c < b < d or c < a < d < b: print("yes") ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n, x[1010]; void read() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &x[i]); } bool check() { for (int i = 1; i < n; ++i) for (int j = i + 1; j < n; ++j) { int a = min(x[i], x[i + 1]), b = max(x[i], x[i + 1]), c = min(x[j], x[j +...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) lis = list(map(int,input().split())) if(n < 3): print("no") else: flag = 0 for i in range(1,n): if(lis[i-1] > lis[i]): r = lis[i-1] l = lis[i] else: l = lis[i-1] r = lis[i] for j in range(i+1,n): if(lis[j-1]...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int z, t, counter = 0; cin >> z; for (int i = 0; i < z; i++) { cin >> t; v.push_back(t); } for (int i = 1; i < z; i++) { int a, b; a = v[i]; b = v[i - 1]; for (int j = 1; j < z; j++) { int x, y; x =...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; int arr[1009]; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &arr[i]); int x1, y1, x2, y2; for (int i = 0; i < n - 1; i++) { x1 = min(arr[i], arr[i + 1]); y1 = max(arr[i], arr[i + 1]); for (int j = i + 1; j < n - 1; j++...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); } boolean b = false; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStre...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; bool bol = false; for (int i = 0; i < n - 1; i++) { for (int j = i + 2; j < n - 1; j++) { int a, b, c, d; a = min(arr[i], arr[i + 1]); b = max(arr[i], arr[...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; /** * * @author Altynbek Nurgaziyev */ public class A { public void solution() throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] f = new int[n]; for (int i = 0; i < n; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; struct ab { int a, b; }; int Shalga(int x1, int y1, int x2, int y2) { if (x1 > y1) swap(x1, y1); if (x2 > y2) swap(x2, y2); if (x1 > x2) { swap(x1, x2); swap(y1, y2); } if (x2 > x1 && x2 < y1 && y1 < y2) return 1; else return -1; } int main() {...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1111; int x[maxn]; int main() { int n, x1, x2, x3, x4, i, j; bool flag = false; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &x[i]); } for (i = 0; i < n - 1; i++) { x1 = x[i], x2 = x[i + 1]; if (x1 > x2) swap(x1, x2); f...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def BinarySearch(arr, ele, lft, r): a = arr toSearch = ele left = lft right = r ans = 0 while left <= right: mid = int(left + ((right - left) / 2)) if a[mid] < toSearch: left = mid + 1 else: ans = a[mid] right = mid - 1 return ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int N; int A[1002]; bool inters; int main() { cin >> N; for (int i = 1; i <= N; ++i) cin >> A[i]; for (int i = 1; i <= N - 1; ++i) for (int j = 1; j <= N - 1; ++j) { int L1 = min(A[i], A[i + 1]), L2 = min(A[j], A[j + 1]); int R1 = max(A[i], A[i + 1]), ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int num; cin >> num; vector<int> tmp(num, 0); for (int i = 0; i < num; ++i) { cin >> tmp[i]; } if (num <= 2) { cout << "no"; return 0; } vector<int> s; vector<int> e; for (int i = 1; i < num; ++i) { s.push_back(min(tmp[i - 1]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; /** * Created with IntelliJ IDEA. * User: orhan */ public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [] points = new int[n]; for(int i = 0; i<n; i++) { points[i] = sc.ne...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) x = list(map(int, input().split())) intervals = [] for i in range(n-1): interval = [x[i], x[i+1]] interval.sort() a, b = interval intervals.append((a,b)) def intersect(t1, t2): combined = [t1, t2] combined.sort() interval1, interval2 = combined if interval2[0] < interv...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) s=raw_input().split(" ") l=[int(x) for x in s] i=n if(i==1 or i==2 or i==3): print "no" else: left=l[2] i=3 flag=0 # print left while(i<n): # print i left=l[i-1] right=l[i] j=0 k=0 if(left>right): j=right k=left else: j=left k=right i1=0 ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) a=list(map(int,input().split())) p=[] for i in range(n-1): p.append([min(a[i],a[i+1]),max(a[i],a[i+1])]) for i in p: for j in p: if i[0]<j[0]<i[1]<j[1] or j[0]<i[0]<j[1]<i[1]: print("yes") exit() print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) a = list(map(int, input().split())) if n <= 3: print('no') else: fg = 0 for i in range(n-3): for j in range(i+2, n-1): if min(a[i], a[i+1]) < min(a[j], a[j+1]) < max(a[i], a[i+1]) < max(a[j], a[j+1]) or min(a[j], a[j+1]) < min(a[i], a[i+1]) < max(a[j], a[j+1]) < max(a[i]...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def check_conf(p1, p2): if p1[0] > p1[1]: p1[0], p1[1] = p1[1], p1[0] if p2[0] > p2[1]: p2[0], p2[1] = p2[1], p2[0] if (p1 == p2): return True return not((p1[0] <= p2[0] and p1[1] >= p2[1]) or \ (p2[0] <= p1[0] and p2[1] >= p1[1]) or \ p1[1] <= p2[0] or p1[0] >= p2[1]) def solve(n,...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() a = map(int, raw_input().split()) ans = "no" for i in xrange(n-1): for j in xrange(n-1): x1, x2 = sorted([a[i], a[i+1]]) x3, x4 = sorted([a[j], a[j+1]]) if x1 < x3 < x2 < x4: ans = "yes" print ans
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(raw_input()) a = map(int, raw_input().split()) for i in xrange(n-1): lo, ro = min(a[i],a[i+1]), max(a[i],a[i+1]) for j in xrange(n-1): ld, rd = min(a[j],a[j+1]), max(a[j], a[j+1]) if lo < ld < ro < rd: print "yes" exit() print "no"
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n = sc.nextInt(); double a[]=new double[n]; for(int i=0; i<n; i++){ a[i]=sc.nextDouble(); } boolean x = false; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; public class Main { static final int N = 1010; static int n; static int[] arr = new int[N]; static Node[] nodes = new Node[N]; static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static BufferedWriter bw = new BufferedWriter(n...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=input() p=map(int, raw_input().split()) flag=0 for i in xrange(len(p)-1): for j in xrange(len(p)-1): x=sorted([p[i],p[i+1]]) y=sorted([p[j],p[j+1]]) if (x[0]<y[0] and y[0]<x[1]<y[1]): flag=1 break if (y[0]<x[0] and x[0]<y[1]<x[1]): flag=1 ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (max(a[i], a[i + 1]) ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int min(int x, int y) { if (x < y) return x; else return y; } int max(int x, int y) { if (x > y) return x; else return y; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cerr...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() a = map(int, raw_input().split()) def solve(): for i in xrange(n-1): for j in xrange(n-1): x1, x2 = sorted([a[i], a[i+1]]) x3, x4 = sorted([a[j], a[j+1]]) if x1 < x3 < x2 and x3 < x2 < x4: return "yes" return "no" print solve()
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.math.BigInteger; import java.util.StringTokenizer; import java.util.regex.Pattern; public class BinarySearch { BufferedReader in; StringTokenizer tokenizer; PrintWriter out; public class Intervals { public int min; public int max; public int length; Intervals (int i, int j) ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; import static java.lang.System.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main{ static PrintStream ps; static boolean inside(int l1, int r1, int l2, int r2){ return (l2>=l1 && r2<=r1) || (l1>=l2 && ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.math.*; import java.util.*; import org.omg.CORBA.Environment; //Codeforces public class MainCodeforces1 { private static MyScanner in; private static PrintStream out; private static boolean LOCAL_TEST = false; private static void solve() throws IOException { int n = in.nextInt();...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class CF358A { static class Pair { int x; int y; public Pair (int x, int y) {this.x = x;this.y = y;}} public static void main(String[] args) { Scanner sc = new Sc...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#http://codeforces.com/problemset/problem/358/A #not accepted n = eval(input()) points = [(int)(i) for i in input().split()] poles = [] ''' left = 0 right = 0 prevDir = '-' currentDir = '-' ''' def is_intersect(points): if(n <= 2): return False; global poles poles.append([points[0],points[1]])...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { static final int INF = (int) 1e9; public static void main(String[] args) throws Exception{ Scanner sc = new S...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, a[1000], i, j; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - 1; j++) { if ((min(a[i], a[i + 1]) < min(a[j], a[j + 1]) && min(a[j], a[j + 1]) < max(a[i], a[i + 1]) && ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
from math import * n=int(input()) li=list(map(int,input().split())) li1=[] #print(len(li)) for i in range(0,n-1): li1.append([li[i],li[i+1]]) for i in li1: i.sort() li1.sort(key=lambda x:x[0]) ans="no" for i in range(1,n-1): for j in range(i): if(li1[i][0]>li1[j][0] and li1[i][0]<li1...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const int max_n = 1011, inf = 1e9 + 100; vector<int> v; bool check(pair<int, int> a, pair<int, int> b) { return a.first < b.first && b.first < a.second && a.second < b.second; } int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { int a; cin >> a; ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
raw_input() xs = map(int, raw_input().split()) outside = None # outside bounding inside = None # inside obstacles last = None prev_x = xs[0] intersect = False for x in xs[1:]: if (inside is not None and inside[0] < x < inside[1]) or (outside is not None and not (outside[0] < x < outside[1])): intersect = T...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
__author__ = 'MatFuck' import sys #sys.stdin = open("1.txt") n = input() a = [int(x) for x in raw_input().split()] p = [[0, 0] for i in range(n - 1)] for id in range(n - 1): p[id][0] = min(a [id], a [id + 1]) p[id][1] = max(a [id], a [id + 1]) p = sorted(p, key = lambda ps:(ps[0],ps[1]), reverse = False) ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; public class DimaandContinuousLine { public static void main(String args[]) { FastReader sc= new FastReader(); PrintWriter out = new PrintWriter(System.out); int t,n,i,j,min,max; String s; n=sc.nextInt(); int arr[]=sc.readArray(n); int flag=0; for(i=0;i...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
from collections import defaultdict import sys n = int(raw_input()) data = raw_input().split() connected = defaultdict(set) data = map(int, data) for i in xrange(len(data) - 1): right = data[i + 1] me = data[i] if me < right: connected[me].add(right) else: connected[right].add(me) #sor...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
N=input() T=map(int,raw_input().split()) for x in xrange(N-1): a=min(T[x],T[x+1]) b=max(T[x],T[x+1]) for j in xrange(N-1): c=min(T[j],T[j+1]) d=max(T[j],T[j+1]) if(a<c<b<d): print "yes" exit() print "no"
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) l=list(map(int,input().split())) l1=[] for i in range(n-1): l1.append([min(l[i],l[i+1]),max(l[i],l[i+1])]) ans='no' for i in l1: for j in l1: a=i[0] b=i[1] if j[0]<b<j[1] and a<j[0]: ans="yes" break if j[0]<a<j[1] and b>j[1]: ans...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) x = list(map(int, input().split())) for i in range(n - 1): a = (min(x[i], x[i + 1]), max(x[i], x[i + 1])) for j in range(i): b = (min(x[j], x[j + 1]), max(x[j], x[j + 1])) if b[0] < a[0] < b[1] < a[1] or a[0] < b[0] < a[1] < b[1]: print("yes") exit() print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] in = new int[n]; in[0] = s.nextInt(); boolean found = false; for(int i = 1; !found && i < n; i++) { in[i] = s.nextInt(); int start1 = Math.min(in[i], ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n; vector<int> a, b; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 0; i < n - 1; i++) { a.push_back(v[i]); b.push_back(v[i + 1]); if (a[i] > b[i]) swap(a[i], b[i]); } bool br = f...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#import math #n, m = input().split() #n = int (n) #m = int (m) #n, m, k = input().split() #n = int (n) #m = int (m) #k = int (k) n = int(input()) #m = int(input()) #s = input() #t = input() g = list(map(int, input().split())) if (n == 1): print("no") #print(l) #c = list(map(int, input().split())) #x1, y1, x2, y2 ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; import java.util.TreeSet; public class A { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] p = new int[n]; TreeSet<Integer> set = new TreeSet<Integer>(); for(int i = 0; i < n; i++){ p[i] = in.n...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.IOException; import java.io.OutputStreamWriter; import java.math.BigDecimal; import java.io.BufferedWriter; import java.util.Locale; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputSt...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.math.*; import java.lang.*; public class main{ public static void main(String[] args) { Scanner cin=new Scanner(System.in); long size=cin.nextLong(); long arr[]=new long[(int)size]; for(int i=0;i<size;++i){ arr[i]=cin.nextLong(); }...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(false); int n, sum1 = 0, sum2 = 0; bool ok = false; cin >> n; int a[n + 1]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; ++i) f...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() v = list(map(int, raw_input().split())) w = [(min(v[x], v[x+1]), max(v[x], v[x+1])) for x in range(0, n-1)] for i in range(0, len(w)): for j in range(0, len(w)): if i == j: continue a, b = w[i][0], w[i][1] c, d = w[j][0], w[j][1] if a < c and c < b and (d < a ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import com.sun.org.apache.bcel.internal.generic.AALOAD; import com.sun.org.apache.bcel.internal.generic.GOTO; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.util.stream.IntStream; impo...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n; int v[1111]; pair<int, int> s[1111]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &v[i]); if (i) { s[i] = make_pair(v[i - 1], v[i]); if (s[i].first > s[i].second) swap(s[i].first, s[i].second); } } sort(s + 1...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n; int x[1005]; int sucess; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x[i]); } sucess = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j || i == n - 1 || j == n - 1) continue; if (x[i]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > inter; int l, r, n, i, vec[10000000]; bool busca(int x, int a, int b) { int j, fi, se; for (j = 0; j < inter.size(); j++) { fi = inter[j].first, se = inter[j].second; if (a <= fi && fi <= b && a <= se && se <= b) { if (fi != a || se...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 23; const int MOD = 1e9 + 9; const int ARRS = 1e3 + 100; int arr[ARRS]; bool inside(int x, int a, int b) { return min(a, b) < x && x < max(a, b); } bool outside(int x, int a, int b) { return x < min(a, b) || max(a, b) < x; } int main() { ios_base::sy...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class CF{public static void main(String[]args)throws IOException{S s=new S();s.s();s.output();}}class S{ void s() throws IOException { int n = NI(); if (n < 4) { sout(...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; int a[1005]; int n; int main() { bool ans = false; cin >> n >> a[0]; for (int i = 1; i < n; i++) { cin >> a[i]; if (a[i] < a[i - 1]) v.push_back(make_pair(a[i], a[i - 1])); else v.push_back(make_pair(a[i - 1], a[i]));...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; import java.util.TreeSet; public class ContinuousLine { public static void main(String[] args) { Scanner in = new Scanner(System.in); int max = in.nextInt(); TreeSet<Integer> tree = new TreeSet<Integer>(); int minNext = 0; int maxNe...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String line = stdin.readLine(); int n = Integer.parseInt(line); int[] x = new int[n]; line = stdi...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
//package com.ahashem.active; import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class DimaAndContinuousLine { public static void main(String[] args) { int t = 1; // sc.nextInt(); StringBuilder builder = new StringBuilder(); while (...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); solve(in); } public static void solve(Scanner in){ int n = in.nextInt(); int[] a = new int[n]; int[] ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Solution { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(n...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(raw_input()) if n > 2: co = list(map(int,raw_input().split())) check = [[min(co[0],co[1]),max(co[0],co[1])]] for i in xrange(1,n-1): flag = -1 # nahi hoga intersect left = min(co[i],co[i+1]) right = max(co[i],co[i+1]) for j in check: if (j[0] >= right) or ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const long long M = 1e7 + 10; long long modpower(long long x, long long y) { long long ans = 1; while (y > 0) { if (y & 1) ans = (ans % M * x % M) % M; y >>= 1; x = (x % M * x % M) % M; } return ans; } long long power(long long x, long long y) { long l...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#pyrival orz import os import sys from io import BytesIO, IOBase input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(raw_input()) a=[int(i) for i in raw_input().split()] flag=0 def check(i): l,r=min(a[i],a[i+1]),max(a[i],a[i+1]) for x in xrange(i): L,R=min(a[x],a[x+1]),max(a[x],a[x+1]) if not( (L<=l and r<=R) or (l<=L and R<=r) or r<=L or R<=l): return 1 return 0 for x in xrange(n): if x+1<n: if check(x): prin...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) arr=list(map(int,input().split())) for x in range(len(arr)-1): x1,x2=(arr[x],arr[x+1]) if x1>x2: x1,x2=x2,x1 for y in range(x+2,len(arr)-1): x3,x4=(arr[y],arr[y+1]) if x3>x4: x3,x4=x4,x3 if x1<x3<x2<x4 or x3<x1<x4<x2: print("yes") ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() a = map(int, raw_input().split()) for i in range(n-1): lo, ro = min(a[i], a[i+1]), max(a[i], a[i+1]) for j in range(n - 1): ld, rd = min(a[j], a[j+1]), max(a[j], a[j+1]) if lo < ld < ro < rd: print 'yes' exit() print 'no'
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> int power(int x, int y) { int res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } int ncr(int n, int r) { int C[r + 1]; memset(C, 0, sizeof(C)); C[0] = 1; for (int i = 1; i <= n...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; int i, j; for (i = 0; i < n; i++) cin >> a[i]; vector<pair<int, int> > l; for (i = 0; i < n - 1; i++) { if (a[i] < a[i + 1]) { l.push_back(make_pair(a[i + 1]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by 875k on 1/3/14. */ public class CF208A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def edge_intersects(edge, l): for other_edge in l: if min(other_edge) < min(edge) and max(other_edge) > min(edge) and max(other_edge) < max(edge): return True if min(other_edge) < max(edge) and min(other_edge) > min(edge) and max(other_edge) > max(edge): return True retur...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; public class a { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[] data = new int[n]; for(int i = 0; i<n; i++) data[i] = input.nextInt(); boolean good = true; for(int i = 0; i<n-1; i++) for(int j = i+1; j<...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
function trim(s) { return s.replace(/^\s+|\s+$/gm, ''); } function tokenize(s) { return trim(s).split(/\s+/); } function tokenizeIntegers(s) { var tokens = tokenize(s); for (var i = 0; i < tokens.length; i += 1) { tokens[i] = parseInt(tokens[i]); }; return tokens; } function main() { var pointNum = parseInt...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import javax.print.attribute.standard.Finishings; public class Dima { public static void main(String[] args) throws NumberFormatException, IOException { Buffe...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @SuppressWarnings("javadoc") public class DimaAndContinuousLine { public DimaAndContinuousLine() throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(raw_input()) x = map(int, raw_input().split()) def isCrossed(i, j): a, b = min(x[i-1], x[i]), max(x[i-1], x[i]) c, d = min(x[j-1], x[j]), max(x[j-1], x[j]) return a < c < b < d or c < a < d < b crossed = False for i in range(1, n): for j in range(1, n): if isCrossed(i, j): ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() ls = map(int,raw_input().split()) if n<=3: print('no') exit(0) c = False for i in range(n-1): for j in range(i+1,n-1): x1 = min(ls[i],ls[i+1]) x2 = max(ls[i],ls[i+1]) x3 = min(ls[j],ls[j+1]) x4 = max(ls[j],ls[j+1]) if x1<x3<x2<x4 or x3<x1<x4<x2: ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n, x = int(input()), list(map(int, input().split())) for i in range(n - 2): for j in range(i + 1, n - 1): a = sorted([sorted([x[i], x[i + 1]]), sorted([x[j], x[j + 1]])]) if a[1][0] > a[0][0] and a[1][0] < a[0][1] and a[1][1] > a[0][1]: print('yes'), exit() print('no')
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
# python 3 """ """ from operator import itemgetter def dima_and_continuous_line(segment_list: list) -> str: segment_list.sort(key=itemgetter(0)) # print(segment_list) for i in range(len(segment_list)): for j in range(i+1, len(segment_list)): if segment_list[i][0] < segment_list[j][0] <...
PYTHON3