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
#!usr/bin/env python def do_points_intersect(xs): if len(xs) <= 2: return "no" seen = [(xs[0], xs[1])] for i in range(2, len(xs)): for s in seen: if ((min(xs[i], xs[i - 1]) < s[0] < max(xs[i], xs[i - 1])) and (s[1] < min(xs[i], xs[i-1]) or s[1] > max(xs[i], xs[i - 1]))) 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
if int(input())<3: print("no") exit(0) m=list(map(int,input().split())) s=set([(min(m[0],m[1]),max(m[0],m[1]))]) p=m[1] m=m[2:] for i in m: a,b=min(i,p),max(i,p) for c,d in s: if a<c<b<d or c<a<d<b: print("yes") exit(0) s.add((a,b)) p=i 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 C208 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] ar = new int[n]; for(int i = 0 ; i < n;i++) ar[i]=sc.nextInt(); for( int i = 2 ; i < n;i++) { for(int j=i-1; j>0;j--) if( ( in(ar[i],ar[...
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 Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner in=new Scanner(System.in); int n,i,j,k,l,p,q,temp,flag=0; n=in.nextInt(); int[] a=new int[n]; for(i=0;i<n;i++) a[i]=in.nextInt(); HashSet<Integer> h=new Ha...
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 { private static final long MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] arr = new int[n]; read(scan, arr); bo...
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> > forbidden; bool not_forbidden(int a); int main() { int n; scanf("%d", &n); if (n <= 2) { printf("no\n"); return 0; } int a, b, c, aux; scanf("%d", &a); scanf("%d", &b); c = b; b = max(a, b); a = min(a, c); const int INF ...
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 sys import itertools import math import collections from collections import Counter ######################### # imgur.com/Pkt7iIf.png # ######################### def sieve(n): prime = [True for i in range(n + 1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p ...
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
#!/usr/bin/env python n = int(raw_input()) x = map(int, raw_input().split()) def inter(p1, p2): a = min(p1) b = max(p1) c = min(p2) d = max(p2) if (a < c < b and b < d) or (c < a and a < d < b): return True return False pairs = zip(x, x[1:]) for p1 in pairs: for p2 in pairs: ...
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
num=int(raw_input()) a=map(int, raw_input().split(' ')) flag=0 for i in range(num): if i==0 or i==1 :continue for j in range(i-1): d=max(a[j],a[j+1]) x=min(a[j],a[j+1]) dd=max(a[i-1],a[i]) xx=min(a[i-1],a[i]) if ((d>dd and x>xx and dd>x) or (dd>d and xx>x and d>xx)): print "yes" flag=1 break if(f...
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.util.*; import java.io.*; public class DimaAndContinousLine { PrintWriter out; StringTokenizer st; BufferedReader br; final int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE; final int mod = 1000000007; void solve() throws Exception { int t = 1; // t = ni(); ...
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, x[1000][2], x2, x1; cin >> n >> x1; for (int i = 1; i < n; i++) { cin >> x2; x[i - 1][0] = min(x2, x1); x[i - 1][1] = max(x2, x1); x1 = x2; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { 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
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Stack; import java.util.StringTokenizer; import java.io.*; public class DimaContinuousLine { private static class MyScanner { ...
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.awt.Point; import java.io.*; public class Main { static StreamTokenizer st; static int get() throws IOException { st.nextToken(); return (int)st.nval; } static class Circle { double r, center; Circle(double r, double center) { ...
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 sys n = int(raw_input()) nums = [int(x) for x in raw_input().split()] L = [nums[0]] idx = 0 for i in xrange(1, len(nums)): val = nums[i] if val < L[idx]: if idx == len(L) - 1 and val < L[0]: L.insert(0, val) idx = 0 continue if idx > 0 and val < L...
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 sys n = int(input()) inp = input().split() x = [int(p) for p in inp] for i in range(0,n-2): for j in range(i+1,n-1): # (i,i+1) vs. (j,j+1) al = min(x[i],x[i+1]) ar = max(x[i],x[i+1]) bl = min(x[j],x[j+1]) br = max(x[j],x[j+1]) if al<bl<ar and ar<br or al<br<ar...
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 = False A = [int(i) for i in input().split()] for i in range(n-2): x1 , x2= min(A[i],A[i+1]),max(A[i],A[i+1]) for j in range(i+1,n-1): X1,X2 = min(A[j],A[j+1]),max(A[j],A[j+1]) if(x1<X1 and X1<x2 and x2<X2): x = True elif(X1<x1 and X2>x1 and X2<x2): x = True if(x): print("yes") else: ...
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 a, x, y; vector<pair<int, int>> pa; vector<int> num; cin >> a; for (int i = 0; i < a; i++) { cin >> x; num.push_back(x); if (i > 0) { y = num[i - 1]; pa.push_back(make_pair(min(x, y), max(x, y))); } } for (int i = 0...
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.util.regex.*; import java.text.*; import java.math.*; import java.awt.geom.*; public class A208 { public static boolean intersect(int a, int b, int c, int d) { if ((Math.min(c, d) > Math.min(a, b) && Math.min(c, d) < Math.max(a, b) && Math.max(c, d) > Math.max(a, b)) || (Ma...
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
#!/usr/bin/env python3 n = int(input()) xs = list(map(int,input().split())) found = False for i in range(n-1): al = min(xs[i], xs[i+1]) ar = max(xs[i], xs[i+1]) for j in range(i): bl = min(xs[j], xs[j+1]) br = max(xs[j], xs[j+1]) if al < bl < ar < br or bl < al < br < ar: ...
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
/* PROG: a LANG: JAVA */ import java.util.*; import java.io.*; public class a { private void solve() throws Exception { //BufferedReader br = new BufferedReader(new FileReader("a.in")); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine(...
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 DimaLine { 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 < n; i++) arr[i] = sc.nextInt(); sc.close(); boolean flag = fa...
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 Intersections { static int inside(int x1, int x2, int a){ if(a<Math.min(x1, x2) || a>Math.max(x1, x2)) return 0; else if (a==x1 || a==x2) return -5; else return 1; } public static void main(String[] args) { // TODO Auto-generated method ...
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 a[1010]; int check(int x, int y, int xx, int yy) { if (x > y) swap(x, y); if (xx > yy) swap(xx, yy); if (y <= xx) return 1; if (yy <= x) return 1; if (x >= xx && y <= yy) return 1; if (x <= xx && y >= yy) return 1; return 0; } int main() { int n; scanf...
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<int> v; struct point { int l; int r; }; point a[100000]; int n; void sort(int l, int r) { if (l >= r) return; int i = l; int j = r; int mid = a[(i + j) / 2].l; while (i <= j) { while (a[i].l < mid) i++; while (a[j].l > mid) j--; if (i <= 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
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b)...
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 N = 10000; int x[N]; pair<int, int> points[N]; int n; bool intersect(const pair<int, int>& a, const pair<int, int>& b) { return a.first < b.first && b.first < a.second && a.second < b.second; } int main() { while (cin >> n) { for (int i = 0; i < n; ++i) ci...
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; inline int min(int x, int y) { if (x < y) return x; return y; } inline int max(int x, int y) { if (x > y) return x; return y; } int x[1010]; int main() { int n; scanf("%d\n", &n); for (int i = 1; i <= n; ++i) scanf("%d ", &x[i]); bool e = true; for (int 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<int> ve; int n, e; bool g(int i, int j) { int a, b, c, d; a = ve[i - 1]; b = ve[i]; c = ve[j - 1]; d = ve[j]; if (a > b) { swap(a, b); } if (c > d) { swap(c, d); } int p1, p2, d1, d2; if (b < d && b > c && a < c) { return true; } ...
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 checkint(a,b,c,d): check=0 if min(a,b)<min(c,d)<max(a,b)<max(c,d) or \ min(c,d)<min(a,b)<max(c,d)<max(a,b): check=1 return check n=int(input()) lis=input().split() for i in range(n): lis[i]=int(lis[i]) intersect=0 for i in range(n-1): for j in range(n-1): if checkint(lis[...
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 take_input(s): #for integer inputs if s == 1: return int(input()) return map(int, input().split()) n = take_input(1) if n == 1: print("no"); exit() a = list(take_input(n)) flag = 0 for i in range(1,n-1): for j in range(i): init_1 = min(a[i],a[i+1]); fin_1 = max(a[i],a[i+1]) 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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] tokens = br.readLine().split("\\s+"); int n = Integer.parseInt(tokens[0]); int[] x = new int[n]; tokens = ...
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Abood3A { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWrit...
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())) c = [] for i in range(n-1): c.append((min(x[i], x[i+1]), max(x[i], x[i+1]))) for i in range(0, len(c)): for j in range(0, len(c)): if c[i][0] < c[j][0] <c[i][1] < c[j][1] or c[j][0] < c[i][0] <c[j][1] < c[i][1]: 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
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException{ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++) { arr[i]=sc.nextInt(); } for(int i=1;i<n-1;i++) { int minx=arr[i]; int miny=arr[i+1];...
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, i, x = 0, y = 0, j; long a[1000]; scanf("%d", &n); for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { x = y = 0; for (j = i + 2; j < n; j++) { if ((a[j] > a[i] && a[j] > a[i + 1]) || (a[j] < 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
#include <bits/stdc++.h> using namespace std; struct unit { long long int a[1000000]; }; long long fact(long long int x) { if (x == 1 || x == 0) return 1; else return x * fact(x - 1); } long long power(long long int x, long long int n) { if (n == 0) return 1; else if (n % 2 == 0) return power(...
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()) r=[int(c)for c in input().split()] r=[sorted(r[i:i+2])for i in range(n-1)] print(['no','yes'][any(a<c<b<d for a,b in r for c,d in r)])
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.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class _Solution implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new...
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()) pos = [int(k) for k in input().split()] sigue = True if len(pos)>2: for i in range(len(pos)-2): x1 = pos[i] x2 = pos[i+1] for k in range(i+1,len(pos)-1): x3 = pos[k] x4 = pos[k+1] if x1<x3<x2<x4 or x3<x1<x4<x2 or x1<x4<x2<x3 or x4<x1<x3<x2...
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> struct data { int a, b; }; int main() { int n; int in[1000 + 100]; struct data p[1000 + 100]; while (scanf("%d", &n) != EOF) { int i; for (i = 0; i < n; i++) scanf("%d", &in[i]); for (i = 0; i < n - 1; i++) { p[i].a = in[i]; p[i].b = in[i + 1]; } 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
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; void solve() { int n; cin >> n; int a[n]; for (int i = (0); i < (n); i++) { cin >> a[i]; } if (n > 3) { int L = a[0], R = a[1]; if (L > R) { swap(L, R); } for (int i = (3); i < (n); i++) { int x = 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
/* package whatever; // don't place package name! */ import java.util.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static int gcd(int a, int b) { if(b==0) return a; return gcd(b, a%b); } public static int lcm(int a, int b) { retur...
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/contest/358/problem/A """ from operator import __and__ import sys def compare(startx,endx,starty,endy) : startx,endx = sorted([startx,endx]) starty,endy = sorted([starty,endy]) if startx <= endx <= starty : return True elif starty <= startx <= endx <= endy : return True elif endy <= ...
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()) ar=map(int,raw_input().split()) l=[] for _ in xrange(n-1): l.append([]) for i in xrange(n-1): l[i].append((ar[i+1]+ar[i])/2.0) l[i].append(abs(ar[i+1]-ar[i])/2.0) flag=1 for i in xrange(n-1): for j in range(i+1,n-1): c1=l[i][0] c2=l[j][0] r1=l[i][1] r2=l[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
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, len(v)-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()) p=map(int,raw_input().split()) flag=1 for x in range(0,n-1): for y in range(0,n-1): ma1 = max(p[x],p[x+1]) ma2 = max(p[y],p[y+1]) mi2 = min(p[y],p[y+1]) mi1 = min(p[x],p[x+1]) if((mi2<ma1 and ma1<ma2) and (mi2>mi1 and mi2<ma1)): flag = 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[1100]; for (int i = 1; i <= n; i++) cin >> a[i]; if (n <= 3) { cout << "no" << endl; return 0; } int f1, f2; for (int i = 1; i <= n; i++) { f1 = 0, f2 = 0; for (int j = i + 2; j <= n; j++) { if (a[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.ArrayList; import java.util.Scanner; public class p1_208 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] points = new int[n]; for (int i = 0; i < n; i++) points[i] = in.nextInt(); Array...
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 sys import stdin from fractions import Fraction def read_int(): return [int(x) for x in stdin.readline().split()][0] def read_ints(): return [int(x) for x in stdin.readline().split()] def char_list(): return [c for c in stdin.readline()][:-1] def line(): return stdin.readline() def print_yes(arg)...
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
I=lambda:map(int, raw_input().split()) F=lambda x, y: (x,y) if x < y else (y, x) n = input() a = I() for i in xrange(n-1): x, y = F(a[i],a[i+1]) for j in xrange(i+1, n-1): u, v = F(a[j], a[j+1]) if not(u>=y or x>=v or x<=u<=v<=y or u<=x<=y<=v): print 'yes' exit(0) print...
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 k in range(n-1): #print(k, k+1, 1234567890) for kk in range(k+1, n - 1): #print(kk, kk+1) #print(k, k+1) #print(kk, kk+1) a = min(arr[k], arr[k+1]) b = max(arr[k], arr[k+1]) c = min(arr[kk], arr[kk+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.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class T358A { class MyComp implements Comparator<int[]> { p...
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.PrintStream; import java.util.Scanner; /** * Created with IntelliJ IDEA. * User: ekrylov * Date: 11/7/13 * Time: 4:25 AM * To change this template use File | Settings | File Templates. */ public class A { public static void main(String[] arg) { new A().solve(); } private voi...
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 a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) { for (int j = i + 1; j + 1 < n; j++) { int x = min(a[i], a[i - 1]); int y = max(a[i], a[i - 1]); if (a[j] > x && a[j] < y && (a[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
//package main; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(...
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.*; public class Main implements Runnable { public void solve() throws IOException { int N = nextInt(); long[] x = new long[N]; for (int i = 0; i < N; i++) { x[i] = nextLong(); } boolean yes = false; for (int 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
import sys import math def intersect(xa1, xa2, xb1, xb2): vmin = min(xa2, xb2) vmax = max(xa1, xb1) if((vmin == xa2 and vmax == xa1) or (vmin == xb2 and vmax == xb1)): return False else: return vmax < vmin n = int(input()) xn = [int(x) for x in (sys.stdin.readline()).split()] x1x2 =...
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 does_intersect(p1, p2): return (not(p1[1] <= p2[0] or p1[0] >= p2[1])) and ((p1[0] > p2[0] and p1[1] > p2[1]) or (p1[0] < p2[0] and p1[1] < p2[1])) n = int(raw_input()) ls = map(int, raw_input().split()) pairs = [(min(ls[i], ls[i+1]), max(ls[i], ls[i+1])) for i in range(n-1)] intersects = False for i, p1 in enum...
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; class Semicircle { public: int startPoint; int endPoint; Semicircle(int _startPoint, int _endPoint) { startPoint = _startPoint; endPoint = _endPoint; } }; int N; int X[1001]; vector<Semicircle> semicircles; int main() { ios::sync_with_stdio(false); cin ...
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()) v = list(map(int, input().split())) intersection_happened = False for i in range(0, n-1): for j in range(i+2, n-1): start_1 = min(v[i], v[i+1]) end_1 = max(v[i], v[i+1]) start_2 = min(v[j], v[j+1]) end_2 = max(v[j], v[j+1]) if start_2 < end_1 and end_2 > st...
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 Prob72 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int [][] array = new int [n][2]; int start = s.nextInt(); int x; int end; int index = -1; for (int i = 0; i < n-1; i++) { x = s.nextInt(); if (x >= ...
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=list(map(int, input().split())) def fn(n,a): if n<3:return 'no' for i in range(2,n-1): for j in range(i-1): p1=(a[j]-a[i])*(a[j]-a[i+1]) p2=(a[j+1]-a[i])*(a[j+1]-a[i+1]) if p1*p2<0:return 'yes' return 'no' print(fn(n,a))
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()) x = [int(y) for y in raw_input().split()] def main(): for i in range(len(x)-1): for j in range(len(x)-1): if i == j : continue else: a1 = min(x[i],x[i+1]) a2 = max(x[i],x[i+1]) b1 = min(x[j],x[j+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
n = int(input()) A = [int(i) for i in input().split()] res = "no" semi_circles = [] for i in range(1, len(A)): if A[i-1] < A[i]: semi_circles.append([A[i-1], A[i]]) else: semi_circles.append([A[i], A[i-1]]) res = 'no' for i in range(len(semi_circles)): for j in range(i+1, len(semi_cir...
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[1005]; struct node { int l, r; } s[1005]; int ind = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } if (n <= 2) puts("no"); else { int flag = 0; int ff = 1; int l = a[0], r = a[1]; if (l > r) { ff...
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, check = 0, c = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { check = 0, c = 0; for (int j = i + 2; j < n; j++) { if (a[j] > a[i] && a[j] > a[i + 1] || a[j] < a[i] && a[j] < 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.util.Scanner; public class A358 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int []values = new int[n]; for (int i = 0; i < n; i++) { values[i] = scan.nextInt(); } boolean flag = fal...
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 a[3001], n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } if (n <= 2) { puts("no"); return 0; } for (int i = 0; i < n - 1; ++i) { for (int j = 0; j < n - 1; ++j) { if ((min(a[i], a[i + 1]) < min(a[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()) inp=list(map(int,input().split())) lst=[] ans="no" for i in range(n-1): lst.append([min(inp[i],inp[i+1]),max(inp[i],inp[i+1])]) for i in lst: for j in lst: if i[0]<j[0]<i[1]<j[1] or j[0]<i[0]<j[1]<i[1]: ans=("yes") print(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
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(); int pre = in.nextInt(); ArrayList<int[]> segs = new ArrayList<int[]>(); f...
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> int a[1005], n, x, y, z, t, k; using namespace std; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n - 2; i++) { for (int j = i + 1; j <= n - 1; j++) { if (a[i] <= a[i + 1]) { x = a[i]; y = a[i + 1]; } else { 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
import java.util.Scanner; import java.io.File; public class A { private Scanner sc; int n; int[] arr = new int [1001]; static int tmp = 0; public static void main(String[] args) throws Exception { A cl = new A(); cl.input(); cl.solve(); cl.output(); } public...
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() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n; cin >> n; long long int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; if (n == 1) cout << "no" << endl; else if (n > 1) { vector<pair<long long int,...
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
# -*- coding: utf-8 -*- """ Created on Thu Aug 27 17:23:46 2020 @author: DELL ## # # # # # # ## # --- --- # # 0 0 # # --- --- # # * . # # ______ # # # ## # # # # # # ## """ n=int(input()) x=list(map(int,input().split())) m=[] t=False for i in range(...
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
""" // Author : snape_here - Susanta Mukherjee """ from __future__ import division, print_function import os,sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def ii(): return int(i...
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::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a[n], b[n]; int c[n + 1]; for (int i = 1; i <= n; i++) { cin >> c[i]; } for (int i = 1; i < n; i++) a[i] = c[i]; for (int i = 1; i < n; i++) b[i] = c[i + 1]; for (int i = 2;...
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 C358 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); } int x1,x2,x3,x4; for (int i = 0; i < n-1;...
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; const double PI = acos(-1.0); const double EPS = 1e-9; const int INF = 0x5ffffff; const int N = 100 * 1000 + 10; int n; int a[N]; bool okay(int x, int y) { int la = a[x - 1], ra = a[x]; if (la > ra) { swap(la, ra); } int lb = a[y - 1], rb = a[y]; if (lb > rb) ...
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() { long long n, x[1000 + 10]; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (max(x[i], x[i + 1]) < max(x[j], x[j + 1]) && min(x[i], x[i + 1]) < 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
import java.util.*; public class semicircle { public static boolean dir(int x,int y){ if(x<y)return true; else return false; } public static boolean change(int []arr,int[]brr,int x,int n){ boolean f=true; for(int i=1;i<brr.length-1;i++){ if(arr[brr[i+1]-n]==0){ ...
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, x[1000], f = 1; int mx, mn; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x[i]); if (i >= 2 && f) { for (int j = 1; j < i; j++) { if (x[j] > x[j - 1]) { mx = j; mn = j - 1; } else { ...
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 long long N = 2e6 + 5; const double E = 1e-9; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n], maxx = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) { for (int j = 1; j < n; 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
#include <bits/stdc++.h> using namespace std; int n, a[1002]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i < n; i++) for (int j = 1; j < n; j++) if (i != j) { int l = min(a[i], a[i + 1]), r = max(a[i], a[i + 1]), x = min(a[j], a[j + 1]), y = max(...
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, x, i; pair<int, int> p[1001]; int main() { cin >> n; cin >> x; p[i].first = x; for (; i < n - 2; i++) { cin >> x; p[i].second = x; p[i + 1].first = x; } cin >> x; p[i].second = x; for (int j = 0; j < n; j++) { if (p[j].first > p[j].sec...
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, flag = 0; cin >> num; int array[num]; for (int i = 0; i < num; i++) { cin >> array[i]; } for (int i = 1; i < num; i++) { int x, y; if (array[i] > array[i - 1]) { x = array[i - 1], y = array[i]; } else { x = array...
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 main() { cin >> n; for (int i = 0; i < n; ++i) cin >> x[i]; for (int i = 0; i < n - 1; ++i) { int i1 = (i + 1) % n; int x1 = min(x[i], x[i1]), x2 = max(x[i], x[i1]); for (int j = 0; j < n - 1; ++j) { if (i == j) continue; ...
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; cin >> n; int x[n]; for (int& e : x) cin >> e; bool intersect = false; for (int i = 0; i < n - 1; i++) { int a = x[i], b = x[i + 1]; if (a > b) swap(a, b); for (int j = 0; j < n - 1; j++) { int c = x[j], d = x[j + 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
n=int(input()) l=list(map(int,input().split())) f=0 for i in range(n-1): for j in range(i+2,n-1): x1,x2=(l[i],l[i+1]) if(l[i]<l[i+1]) else (l[i+1],l[i]) x3,x4=(l[j],l[j+1]) if(l[j]<l[j+1]) else (l[j+1],l[j]) if((x1<x3<x2<x4) or (x3<x1<x4<x2)): f=1 break if(f==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
def main(): n=int(raw_input()) x=map(int,raw_input().split()) p=[[0,0]]*(n-1) for i in range(n-1): p[i] = [min(x[i],x[i+1]),max(x[i],x[i+1])] p.sort() for i in range(n-2): for j in range(i+1,n-1): if (p[i][0]<p[j][0] and p[j][0]<p[i][1]) and p[i][1]<p[j][1]: print 'yes' ret...
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> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; int main() { int n, i, x = 0, y = 0, j; int a[1000]; scanf("%d", &n); for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) { x = y = 0; for (j = i + 2; j < n; j++) { if ((a[j] > a[i] && 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
#import sys #sys.stdin = open('in') n = int(raw_input()) nums = map(int,raw_input().split()) ok = True lst = [] for i in range(n - 1): lst.append((min(nums[i], nums[i + 1]), max(nums[i], nums[i + 1]))) for i in range(n - 1): if not ok: break for j in range(i + 1, n - 1): if lst[i][0] < lst[...
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
def f(): n = int(input()) - 1 x = list(map(int, input().split())) p = [(x[i], x[i + 1]) if x[i] < x[i + 1] else (x[i + 1], x[i]) for i in range(n)] p.sort() for j, (x, y) in enumerate(p, 1): while j < n and p[j][0] == x: j += 1 while j < n and p[j][0] < y: if p[j][1] > y...
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())) for i in range(n-1): for j in range(n-1): x,y=(sorted([a[i],a[i+1]])) m,t=sorted([a[j],a[j+1]]) if x<m<y<t or m<x<t<y: 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
#include <bits/stdc++.h> using namespace std; int n; int x[1005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { int a = x[i]; int b = x[i + 1]; int c = x[j]; int d = x[j + 1]; if (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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Dima { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); 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
/** * Created with IntelliJ IDEA. * User: flevix * Date: 25.10.13 * Time: 19:26 */ import java.io.*; import java.util.*; import static java.lang.Math.min; import static java.lang.Math.max; public class A { FastScanner in; PrintWriter out; boolean checkIntersect(int x1, int x2, int y1, int y2) { ...
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()) v = list(map(int, input().split())) intersection_happened = False for i in range(0, n-1): for j in range(i+2, n-1): start_1 = min(v[i], v[i+1]) end_1 = max(v[i], v[i+1]) start_2 = min(v[j], v[j+1]) end_2 = max(v[j], v[j+1]) if start_1 < start_2 < end_1 < en...
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()) k=list(map(int,input().split())) new=[k[i:i+2]for i in range(n-1)] ans='no' for a,b in new: for c,d in new: if a<c<b<d or a<d<b<c or b<d<a<c or d<a<c<b: ans='yes' print(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
/* * * Date: 07 September 2019 * Time: 01:03:00 */ import java.io.*; import java.util.*; public class dc { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[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> int main() { int j, n, x[2000], i, p = 0, q = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &x[i]); } for (i = 1; i < n; i++) { p = q = 0; for (j = i + 2; j <= n; j++) { if ((x[j] > x[i] && x[j] > x[i + 1]) || (x[j] < x[i + 1] && x[j] < x[i])) p+...
CPP