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; bool intersecting(int c11, int c12, int c21, int c22); int main() { int n; cin >> n; vector<int> v(n, 0); int flag = 0; for (int i = 0; i < n; ++i) { cin >> v[i]; if (!flag) for (int j = 1; j < i; ++j) if (intersecting(v[j], v[j - 1], v[i], v...
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, x = input(), map(int, raw_input().split()) if n < 4: print "no" else: l, r, p = min(x[:2]), max(x[:2]), x[2] o = p < l or p > r for x in x[3:]: if x > l and x < r if o else x < l or x > r: print "yes" break if not o: l, r = l if x < p else p, r if x > p...
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 a[1111]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i < n; i++) for (int j = i + 2; j < n; j++) { int x1 = a[i], y1 = a[i + 1], x2 = a[j], y2 = a[j + 1]; if (x1 > y1) swap(x1, y1); if (x2 > y2) s...
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(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): #print '000' # print l,r,L,R # print 'i=',i return 1 return...
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 num; int points[1000]; int i, j; int tmp_max[1000], tmp_min[1000]; bool flag = false; cin >> num; for (i = 0; i < num; i++) cin >> points[i]; for (i = 0; i < num - 1; i++) { (points[i] < points[i + 1]) ? (tmp_min[i] = points[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 sys _ = raw_input() p = map(int, raw_input().split()) pairs = [(p[i], p[i+1]) for i in range(len(p) - 1)] pairs = map(sorted, pairs) pairs = sorted(pairs, key= lambda s: s[0]) for i, t in enumerate(pairs): j = i + 1 while j < len(pairs) and pairs[j][0] < pairs[i][1]: if pairs[i][0] != pairs[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
import sys from collections import defaultdict, Counter from itertools import permutations, combinations from math import sin, cos, asin, acos, tan, atan, pi sys.setrecursionlimit(10 ** 6) def pyes_no(condition, yes = "YES", no = "NO", none = "-1") : if condition == None: print (none) elif condition : pri...
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()) def solve(): for i in xrange(n-1): for j in xrange(n-1): x1 = a[i] x2 = a[i+1] if x1 > x2: x1, x2 = x2, x1 x3 = a[j] x4 = a[j+1] if x3 > x4: x3, x4 = x4, x3 if x1 < x3 < x2 and ...
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; bool v = 0; cin >> n; int x[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 (v) break; if (max(x[i], x[i + 1]) < max(x[j], x[j + 1]) && mi...
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; // acc public class DimaContinuesLine { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokeni...
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.ArrayList; import java.util.List; import java.util.Scanner; public class dimaAndContinuousLine { public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); class Point{ int x; int y; Point(int x,int y){ this.x=x; this.y=y; } } List...
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())) segs = [sorted((a[i], a[i + 1])) for i in range(n - 1)] for i in range(n - 1): for j in range(n - 1): if segs[i][0] < segs[j][0] < segs[i][1] < segs[j][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=[*map(int,input().split())] b=[] for i in range(n-1): b.append([min(a[i],a[i+1]),max(a[i],a[i+1])]) for i in range(n-1): for j in range(n-1): if i==j: continue if b[i][0]<b[j][0]<b[i][1]<b[j][1] or b[i][0]<b[j][1]<b[i][1]<b[j][0]: 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.*; public class CF358A { static class Point{ int a; int b; Point(int a,int b){ ...
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
inf = int(1e9+5) n = int(input()) ar = list(map(int, input().split())) pairs = [] for i in range(n-1): pair = (min(ar[i],ar[i+1]), max(ar[i], ar[i+1])) pairs.append(pair) # print(pairs) flag = False for i in range(len(pairs)-1): x1 = pairs[i][0] x2 = pairs[i][1] for j in range(i+1, len(pair...
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 a[1005]; int main() { int n; while (cin >> n) { for (int i = 0; i < n; i++) scanf("%d", &a[i]); bool flag = 0; for (int i = 0; i < n - 1; i++) { int l = min(a[i], a[i + 1]); int r = max(a[i], a[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
#include <bits/stdc++.h> using namespace std; int points[((int)1e3)]; class line { public: void init() { int N; cin >> N; for (int i = 0; i < N; i += 1) cin >> points[i]; for (int i = 0; i < N - 1; i += 1) { int x1 = points[i], x2 = points[i + 1]; if (x1 > x2) swap(x1, x2); for (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
#include <bits/stdc++.h> const long long MXN = 1e6 + 1; const long long MNN = 1e3 + 1; const long long MOD = 1e9 + 7; const long long INF = 1e18; using namespace std; long long n, m, b[MXN], mx = -1, mn = INF, a, ans, k, sum, x, q, c[MXN], pr[MXN]; bool used[MXN]; int main() { ios_base::sync_w...
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,l=int(input()),list(map(int,input().split())) for i in range(n-1): for j in range(n-1): x=sorted([l[i],l[i+1]])+sorted([l[j],l[j+1]]) if x[0]<x[2]<x[1]<x[3]: exit(print('yes')) 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 p[20000]; bool pend(int a, int b, int c, int d) { if (a > b) swap(a, b); if (c > d) swap(c, d); if (a > c) { swap(a, c); swap(b, d); } return a < c && b > c && b < d; } int main() { cin >> n; for (int i = 0; i < n; ++i) cin >> p[i]; bool c...
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; using namespace std; int main() { long long int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; ; bool flag = true; for (int i = 1; i < n - 1; i++) { long long int maxi = max(a[i], a[i + 1]); long long int mini = min(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
n = int(input()) Min = -1e10 Max = 1e10 ans = "no" def f(x, y): return x[0] < y[0] < x[1] < y[1] or \ y[0] < x[0] < y[1] < x[1] xs = list(map(int, input().split())) for i in range(1, len(xs) - 1): for j in range(0, i): if f([min(xs[i:i+2]), max(xs[i:i+2])], [min(xs[j:j+2]), max(xs[j:j+2])]): 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
//package com.example.hackerranksolutions; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Scanner; public class CodeforcesProblems { stati...
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 swap(int a, int b) { } public static void main(String[] args) { int x1,x2,x3,x4; int c = 0; Scanner myObj = new Scanner(System.in); int n = myObj.nextInt(); int a[] = new int[n]; for(int i=0;i<n;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.*; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; public class Temp2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.re...
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
/* Link of Question : http://codeforces.com/contest/358/problem/A */ import java.io.*; import java.util.*; public class DimaAndContinuousLine { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int A[]=new int[n]; fo...
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 #sys.stdin = open("in.txt", "r") n = input() a = map(int, raw_input().split()) if n < 3: print "no" else: b = [] for i in xrange(n-1): b.append([a[i], a[i+1]]) good = False for i in xrange(n-1): b[i].sort() for i in xrange(n-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; const int MAX_N = 77; const double EPS = 1e-9; const int MOD = 1000007; const int INF = 0x7fffffff; template <class Int> inline int size(const Int &a) { return (int)a.size(); } int main() { ios::sync_with_stdio(false); int n; cin >> n; vector<pair<int, int> > ans;...
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 test(): n=int(input()) points=list(map(int,input().split())) for i in range(n-1): a=points[i] b=points[i+1] if(a>b): temp=a a=b b=temp for j in range(i): if(points[j]>=a and points[j]<=b): if(j>0 and (points[...
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): l1, r1 = min(a[i], a[i + 1]), max(a[i], a[i + 1]) for j in range(n - 1): l2, r2 = min(a[j], a[j + 1]), max(a[j], a[j + 1]) if l1 < l2 < r1 < r2: 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.PrintWriter; import java.util.Scanner; public class A358 { static Scanner in = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int n = in.nextInt(); int data[] = new int [n]; int ans = 0; b...
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.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { //Scanner sc = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStr...
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())) p = x[0] m = [] for i in range(1, n): for a, b in m[:-1]: if (a < p < b) ^ (a < x[i] < b): print("yes") exit() m.append([min(p,x[i]),max(p,x[i])]) p = x[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
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 10; const double eps = 1e-6; int a[N]; int main() { int n, i, j, f; double d, r1, r2; while (~scanf("%d", &n)) { f = 0; for (i = 0; i < n; i++) { scanf("%d", &a[i]); for (j = 1; j < i; j++) { d = fabs((double)(a[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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ContinuousLine { public static void main (String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] strN...
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.Scanner; public class div2a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n == 1 || n == 2) { System.out.println("no"); return; } int a[] = new int[n + 1], x[] = new int[n + 1], y[] = new int[n + 1]; for (int i = 1; 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
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; /* * @author Mahmoud Aladdin <aladdin3> * */ public class Main { public static void main (String[] args) throws java.lang.Exception { InputReader scan = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out...
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.Scanner; import java.util.TreeSet; public class Main { 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 maxNext = 0; int inOut ...
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())) coordinates = [] for i in range(0,n-1): x = a[i] y = a[i+1] coordinates.append([x,y]) # print(coordinates) f = 'no' for i in range(0,n-2): if(f == 'yes'): break for j in range(i+1,n-1): # print(j) chota1 = min(coordinates[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
#include <bits/stdc++.h> using namespace std; const int EPS = 1e-6; const int INF = (int)(INT_MAX - 100); const long long mod = (int)(1e+9 + 7); const int N = (int)(0); int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) scanf("%d", &v[i]); n--; vector<pair<int, int> > s(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
#include <bits/stdc++.h> int main() { int n, a[2000]; bool check = false; scanf("%d", &n); memset(a, sizeof(a), 0); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } for (int i = 0; i < n - 1; ++i) { if (!check) for (int j = 0; j < n - 1; ++j) { if (j != i && i != j + 1 && 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; bool check(pair<int, int> a, pair<int, int> b) { if (a.first > b.first && a.first < b.second && (a.second > b.second || a.second < b.first)) return true; if (a.second > b.first && a.second < b.second && (a.first > b.second || a.first < b.first)) retu...
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 A[1005]; vector<pair<int, int> > V; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; if (n == 1) { cout << "no"; return 0; } for (int i = 1; i < n; i++) V.push_back(make_pair(min(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
t=raw_input() a=map(int,raw_input().split()) def mi(p1,p2): if p1<p2: return p1 else: return p2 def ma(p1,p2): if p1>p2: return p1 else: return p2 def be(p1,p2,p): if p>mi(p1,p2) and p<ma(p1,p2): return 1 elif p>ma(p1,p2) or p<min(p1,p2): return -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()) s = [int(i) for i in input().split()] s = [s[i:i+2] for i in range(n-1)] f = 0 for i in range(n-1): a,b = min(s[i]),max(s[i]) for j in range(n-1): if i!=j: c,d = min(s[j]),max(s[j]) if (a<c and c<b and b<d) or (c<a and a<d and 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
n = int(raw_input()) m = map(int, raw_input().split()) res = "no" for i in range(1, n): for j in range(1, i - 1): l = min(m[j], m[j - 1]) r = m[j] + m[j - 1] - l if m[i]> l and m[i] < r: if not m[i - 1] > l or not m[i - 1] < r: res = "yes" if m[i - 1]> l and m[i - 1] < r: if not m[i] > l or not m[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
import java.io.*; import java.util.*; import java.math.*; import java.util.stream.Collectors; import java.util.stream.*; public class Main { static class Pair { int x,y; Pair(int x, int y) { this.x = x; this.y = y; } } public static void main(String[] ...
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 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); String []str=br.readLine().split(" "); int []arr=new int[n]; fo...
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
// author: Ahmed A.M import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); //S1 p1 = new S1(); p1.solve(); //S2 p2 = new S2(); p2.solve(); //S3 p3 = new S3(); p3.solve(); //S4 p4 = new S4(); p4.solv...
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 int L = 1010; struct semicircle { int a, b; } b[L]; int a[L], n, flag; void init(void) { cin >> n; int i; for (i = 1; i <= n; i++) scanf("%d", &a[i]); for (i = 1; i < n; i++) b[i].a = min(a[i], a[i + 1]), b[i].b = max(a[i], a[i + 1]); } int pd(int a, 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
def Check(I,J): if Num[I][0]==Num[J][0]: if Num[I][1]==Num[J][1]: return 1 elif Num[J][0]<Num[I][1]and Num[I][1]<Num[J][1]: return 1 return 0 N=int(input()) Tmp=list(map(int,input().split())) Num=[(min(Tmp[I-1],Tmp[I]),max(Tmp[I-1],Tmp[I]))for I in range(1,N)] Num.sort() Flg=0 fo...
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.*; import java.math.*; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub InputStream inputstream = System.in; OutputStream outputstream = System.out; InputReader 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
def line(lst): b = list() for i in range(len(lst) - 1): b.append((min(lst[i], lst[i + 1]), max(lst[i], lst[i + 1]))) for i in range(len(b)): for j in range(len(b)): if b[i][0] < b[j][0] < b[i][1] < b[j][1] or b[j][0] < b[i][0] < b[j][1] < b[i][1]: return "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> int main() { int n; scanf("%d", &n); int a[n]; int i; for (i = 0; i < n; i++) scanf("%d", &a[i]); int f1 = 0, j, f2; for (i = 0; i < (n - 1); i++) { f1 = 0; f2 = 0; for (j = i + 2; j < n; j++) { if ((a[j] > a[i] && a[j] > a[i + 1]) || (a[j] < a[i] && 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
def do_pairs_intersect(start1, end1, start2, end2): if ((end1 <= start2 or start1 >= end2) or (start2>=start1 and start2<=end1 and end2>=start1 and end2<=end1) or (start1>=start2 and start1<=end2 and end1>=start2 and end1<=end2)): return False return True def is_intersecting(points): ...
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.Arrays; import java.util.Scanner; public class Dima_and_Continuous_Line { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] arr = new int[n]; for (int i = 0 ; i < n ; i++) { arr[i] = scan.nextInt(); } System.out.println(solv...
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()) li=[int(x) for x in input().split()] if n==1 or n==2 or n==3: print('no') else: possible=True for i in range(1,n): x1,x2=min(li[i-1],li[i]),max(li[i-1],li[i]) for j in range(i+1,n): x3,x4=min(li[j-1],li[j]),max(li[j-1],li[j]) if x1<x3 and x3<x2 and x2<x...
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 sys def fun(x1,x2,y1,y2): if x1<x2: if (y1<x1 and y2>x1 and y2<x2) or (y2<x1 and y1>x1 and y1<x2): return True elif (y1>x1 and y1<x2 and y2>x2) or (y2>x1 and y2<x2 and y1>x2): return True else: if (y1<x2 and y2>x2 and y2<x1) or (y2<x2 and y1>x2 and y1<x1): ...
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
l=lambda: map(int,raw_input().split()) n=input() a=l() d=[(min(a[i-1],a[i]),max(a[i-1],a[i]),abs(a[i]-a[i-1])) for i in range(1,n)] d.sort(key=lambda e:(e[0],e[2])) for i in range(n-1): x,y=d[i][0],d[i][1] for j in range(n-1): if i==j:continue X,Y=d[j][0],d[j][1] if (x<X<y and Y>y)...
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()) c = list(map(int, input().split())) for i in range(n - 1): min1 = min(c[i], c[i + 1]) max1 = max(c[i], c[i + 1]) for j in range(i + 1, n - 1): min2 = min(c[j], c[j + 1]) max2 = max(c[j], c[j + 1]) if (min2 > min1 and min2 < max1) and max2 > max1: print('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
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; int a[1000]; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n - 1; i++) { int x, y, f1 = 0, f2 = 0; x = min(a[i], a[i + 1]); y = max(a[i], a[i + 1]); for (j = i + 2; j < n; j++) { 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
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); i += 1 - 2 * ((0) > (n))) cin >> a[i]; if (n <= 3) ...
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 arr[1001]; int n; bool isi(int x1, int x2, int y1, int y2) { if (x2 <= y1) return 0; if (y2 <= x2) return 0; if (x2 <= y2 && x1 == y1) return 0; return 1; } void get(int x1, int y1, int x2, int y2, int &x, int &y) { x = -1; y = -1; if (x1 >= x2 && y1 <= y2...
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 a, int b) { if (a < b) return (a); else return (b); } int main() { int n, arr[1005], flag = 0, a, b, i, j, c, d; cin >> n; for (i = 1; i <= n; i++) cin >> arr[i]; if (n == 1 || n == 2 || n == 3) flag = 1; else { for (i = 3; 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); cout.tie(NULL); int len; cin >> len; vector<pair<int, int>> join; int arr[len]; for (int i = 0; i < len; i++) cin >> arr[i]; for (int i = 1; i < len; i++) { int mi = min(arr[i - 1], arr[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.BufferedInputStream; import java.util.Scanner; /** * Created by jizhe on 2015/12/18. */ public class DimaAndContinuousLine { public static void main(String[] args) { Scanner in = new Scanner(new BufferedInputStream(System.in)); int N = in.nextInt(); int[] left = new int[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.*; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int 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; int main() { int n; string ans = "no"; cin >> n; vector<int> lineas(n); for (int i = 0; i < n; i++) { int a; cin >> a; lineas[i] = a; } int minimo; int maximo; for (int i = 0; i < n - 1; i++) { minimo = min(lineas[i], lineas[i + 1]); ma...
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 Dima_and_Continuous_Line { public static void main(String args[]) { Scanner s1 = new Scanner(System.in); int n = s1.nextInt(); int a[] = new int[n]; for(int i=0;i<n;i++) a[i] = s1.nextInt(); s1.close(); for(int i=1;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
import sys import math from sys import stdin, stdout # Most Frequently Used Number Theory Concepts # SOE(helper function of get gcd) def sieve(N): primeNumbers = [True]*(N+1) primeNumbers[0] = False primeNumbers[1] = False i = 2 while i*i <= N: j = i if primeNumbers[j]: ...
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())) f=0 for i in range(n-1): a=x[i] if x[i]<x[i+1] else x[i+1] b=x[i+1] if a==x[i] else x[i] for j in range(i+2,n-1): c= min(x[j],x[j+1]) d = max(x[j],x[j+1]) if a<c and c<b and b<d: f=1 break elif c<a and a<d and d<b: f=1 break if f: break if f...
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() 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 java.util.*; import java.lang.*; import java.io.*; public class DimaandContinuousLine { public static void main(String[] args) throws java.lang.Exception { // your code goes here try { // Scanner sc=new Scanner(System.in); FastReader sc = new FastReader(); ...
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 main(): n = int(input()) a = list(map(int,input().split())) for i in range(n-1): for j in range(n-1): if min(a[i],a[i+1])<min(a[j],a[j+1]) and min(a[j],a[j+1])<max(a[i],a[i+1]) and max(a[i],a[i+1])<max(a[j],a[j+1]): print("yes") return print("no") return main()
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.math.*; public class A { static Seg s[]; public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n; n = sc.nextInt(); int p[] = new int[n]; s = new Seg[n]; for(int i = 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; long x, y, num[2009]; bool flag = true; scanf("%d%ld", &n, &num[1]); for (int i = 2; i <= n; i++) { scanf("%ld", &num[i]); } num[0] = num[1]; num[n + 1] = num[n]; for (int i = 1; i <= n; i++) { x = min(num[i - 1], num[i]); y...
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())) maxx=l[0] minn=l[0] for i in range(0,n-1): if l[i+1]>l[i]: if l[i]>minn and l[i]<maxx and l[i+1]>maxx: print("yes") exit() elif l[i]<minn and l[i+1]>minn and l[i+1]<maxx : print("yes") exit() else: if l[i]>maxx: maxx=l[i] if l[i]<minn: ...
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 Solution{ public static void main(String []args){ Solution ob=new Solution(); ob.go(); } void go() { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if (n<=3) {pry();return;} ...
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; using namespace chrono; int SetBit(int n, int x) { return n | (1 << x); } int ClearBit(int n, int x) { return n & ~(1 << x); } int ToggleBit(int n, int x) { return n ^ (1 << x); } bool CheckBit(int n, int x) { return (bool)(n & (1 << x)); } int dx8[] = {1, 1, 0, -1, -1, -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, a[1111], x, y, x2, y2; bool inter(int a, int b, int x, int y) { if (a > b) swap(a, b); if (x > y) swap(x, y); if (a < x && b > x && b < y) return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; 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; int n, x[1000]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> x[i]; for (int j = 1; j < i - 1; ++j) { bool l = (x[i] > min(x[j], x[j - 1]) && x[i] < max(x[j - 1], x[j])); bool r = (x[i - 1] > min(x[j], x[j - 1]) && x[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
n = input() x = map(int,raw_input().split()) for i in xrange(n-1): a,b = sorted((x[i],x[i+1])) for j in xrange(n-1): c,d = sorted((x[j],x[j+1])) if a < c < b < d: print 'yes' exit(0) 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(raw_input()) r = [int(c) for c in raw_input().split()] r = [list(sorted(r[i:i+2])) for i in xrange(n-1)] print ['no','yes'][any(a<c<b<d for a,b in r for c,d in r)]
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.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int N = sc.ni(); int M = 2000001; int[] vals = new int[N]; for (int i = 0; i < N; i++) vals[i] = 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
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[]args)throws IOException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(bf.readLine()); String s=bf.readLine(); Strin...
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[10000]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } if (n <= 3) { cout << "no" << endl; return 0; } for (int i = 0; i < n; i++) { bool flag1 = false, flag2 = false; for (int j = i + 2; 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, m, a, b, s1, s2, s; void faster() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { faster(); int n, a = 0, b = 0, y = 0, x = 0; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) cin >> arr[i]; for (int i = 0; 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
n=input() a=map(int,raw_input().split()) b=[] for i in range(n-1): b.append([a[i],a[i+1]]) b[i].sort() for i in range(n-1): for j in range(i+1,n-1): if (b[j][1]>b[i][1] and b[j][0]>b[i][0] and b[j][0]<b[i][1]) or (b[i][1]>b[j][1] and b[i][0]>b[j][0] and b[i][0]<b[j][1]): # print b[i],b[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
#include <bits/stdc++.h> using namespace std; struct pr { int a; int b; }; int main() { int n, i, j, cnt = 0, flag = 0, a, b; vector<pr> vec; vector<int> point; cin >> n; for (i = 0; i < n; i++) { cin >> j; point.push_back(j); } for (i = 0; i < n - 1; i++) { if (point[i] > point[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> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n, input; bool intersect; std::vector<int> arr; std::cin >> n; for (int i = 0; i < n; ++i) { std::cin >> input; arr.push_back(input); } intersect = false; for (int i = 0; i < n - 2; ++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
#include <bits/stdc++.h> using namespace std; int main() { int a[1005]; long n, i, x = 0, y = 0, j; cin >> 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] && a[j] < a[i + 1])) 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 x[1111]; int judge(int i, int j) { int a = x[i], b = x[i + 1], c = x[j], d = x[j + 1]; if (a > b) swap(a, b); if (c > d) swap(c, d); if (a < c && b < d && b > c) return 1; if (c < a && d < b && d > a) return 1; return 0; } int main() { int n, i, j; 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
def self_intersect(points:list): for i in range(len(points)): check_point = points[i] for j in range(len(points)): if i != j: check_point2 = points[j] if check_point[0] < check_point2[0] < check_point[1] < check_point2[1]: return True ...
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 { FastReader sc = new FastReader(); int n = sc.nextInt(); int [] arr = new int[n]; for (int i =0;i<n;i++) { arr[i] = sc.nextInt(); } boolean flag = true; for (int i =0;i<n-1;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
n=input() a=map(int,raw_input().split()) for i in range(n-1): z,b=min(a[i],a[i+1]),max(a[i],a[i+1]) for j in range(n-1): c,d=min(a[j],a[j+1]),max(a[j],a[j+1]) if z < 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
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int point; vector<pair<int, int> > segment(n); for (int i = 0; i < n; i++) { cin >> point; if (i == 0) segment[i] = make_pair(point, point); else segment[i] = make_p...
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 DimaAndContinuousLine { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String input = bf.readLine(); String input2 = ...
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.lang.*; public class Solution{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] arr = new int[n]; for(int i = 0 ; i < n ; i++) arr[i] = in.nextInt(); for(int i = 0 ; i < n - 2 ; i++){ int x1...
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() a=list(map(int,raw_input().split())) if n<=2: print "no" else: lst=[] for i in range(n-1): x=max(a[i],a[i+1]) y=min(a[i],a[i+1]) lst.append((y,x)) l=len(lst) flag=0 for i in range(l): for j in range...
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 main() { int n, *a, i, flag, r1, r2, in, k = 1; scanf("%d", &n); a = new int[n]; for (i = 0; i < n; i++) scanf("%d", &a[i]); if (n <= 3) printf("no"); else { if (a[0] < a[1]) { r1 = a[0]; r2 = a[1]; } else { r1 = a[1]; r2 = a[0]; } fla...
CPP