Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n, m, a[3000], i, x, y, l, r, j, k; bool ok = 1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (i = 1; i <= n; ++i) cin >> a[i]; for (i = 1; i < n - 1 && ok; ++i) for (j = i + 1; j < n && ok; ++j) { x = 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class DimaAndContinuuousLine { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLi...
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 N = 1000, geps = 10; int n, a[N + geps]; void Init() { scanf("%d", &n); for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]); } void Solve() { Init(); for (int i = (1); i <= (n - 1); ++i) { for (int j = (i + 1); j <= (n - 1); ++j) { int x1 = 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
//package dima.and.continous.line; import java.util.Scanner; public class DimaAndContinousLine { 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.nextIn...
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; long long ipow(long long base, long long exp) { long long result = 1; while (exp) { if (exp & 1) result *= base; exp >>= 1; base *= base; } return result; } int main() { int n; scanf("%d", &n); pair<int, int> v[10000]; int A[10000]; int ind = 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
n = int(input().strip()) points = list(map(int, input().strip().split())) lst = [] val = False for i in range(n - 1): item = [points[i], points[i+1]] item.sort() lst.append(item) for x in range(n - 1): arc1 = lst[x] for y in range(x, n - 1): arc2 = lst[y] if arc1[0] < arc2[0] and arc...
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 Codeforces358A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; for(int i = 0; i < n; i++){ x[i] = sc.nextInt(); for(int j = 0; j < i - 1; j++){ if(((x[i] < Math.max(x[j],x[j+1]) && x[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.util.*; public class DimaAndContinuousLine { public static void main(String... args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int[] t = new int[n]; for (int i = 0; i < n; i++) { t[i] = cin.nextInt(); for (int j = i - 2; j > 0; j--) { int a = Math.min(t[j], t[j - 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; void solve() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; bool ans = false; for (int i = 0; i < n - 2; i++) { int x1 = min(v[i], v[i + 1]); int x2 = max(v[i], v[i + 1]); for (int j = i + 1; j < n - 1; j++) { 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
import java.util.*; public class Main { public static int fun(int n) { if(n == 0) return 0; if(n > 0) return 1; return -1; } public static void main(String args[]) { Scanner cin = new Scanner(System.in); int n; n = cin.nextIn...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do 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, ch[1050], i, j, flag, a, b, c, d; while (~scanf("%d", &n)) { flag = 1; for (i = 0; i < n; i++) { scanf("%d", &ch[i]); if (i > 2) { b = ch[i]; a = ch[i - 1]; if (a > b) swap(a, b); for (j = 0; j < 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 intger (l): ans=[] for i in l : ans.append(int(i)) return ans n=int(input()) x=intger(input().split()) d=[] for i in range(1,len(x)): d.append(sorted([x[i],x[i-1]])) flag=False for i in d: for j in d: if i==j : continue else: if (i[0]<j[0] and j[0...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p[n]; int flag = -1; for (int i = 0; i < n; i++) cin >> p[i]; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (i == j) continue; int a, b, c, d; a = min(p[i], p[i + 1]); b = p[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
n = int(input()) l = list(map(int,input().split())) p = [] for i in range(n-1): p.append([min(l[i],l[i+1]),max(l[i],l[i+1])]) for i in p: for j in p: if j[1]>i[1]>j[0]>i[0] or i[1]>j[1]>i[0]>j[0]: print('yes') exit() print('no')
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) a = list(map(int, input().split(' '))) f = False for j in range(len(a)-2): #------------------------# for i in range(j,len(a)-3): if a[j]<a[i+2]<a[j+1]<a[i+3] or a[j]<a[i+3]<a[j+1]<a[i+2] or a[i+2]<a[j]<a[i+3]<a[j+1] or a[i+3]<a[j]<a[i+2]<a[j+1] or a[j+1]<a[i+2]<a[j]<a[i+3] or a[j+1]<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
import java.io.*; import java.util.*; import static java.lang.Math.*; public class A { public static void main(String[] args) throws IOException { A solver = new A(); solver.solve(); } private void solve() throws IOException { FastScanner sc = new FastScanner(System.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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class DimaContinuesLine { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st ...
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())) 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]) < max(a[i], a[i + 1]) < max(a[j], a[j + 1]) or \ min(a[j], a[j + 1]) < min(a[i], a[i + 1]) < max(a[j], a[j + 1]) < max(a[i], a[i + 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
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
def main(): n = int(input()) if n <= 2: return False a = list(map(int, input().split(' '))) s = [(min(a[i], a[i+1]), max(a[i], a[i+1])) for i in range(n-1)] for i, p1 in enumerate(s): for j, p2 in enumerate(s): if i == j: continue if p1[0] < p2...
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 CF { void solve() { int n = in.nextInt() ; int[] x = new int[n]; for (int i = 0; i < n; i++) x[i] = in.nextInt(); for (int i = 0; i < n - 1; i++) for (int j = 0; j < n - 1; j++) { int x1 = x[i], x2 = x[i + 1]; int y1 = x[j], y2 = x[j + 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
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solver { public static void main(String[] Args) t...
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(input()) L=[int(i) for i in input().split()] for i in range(n-1): if L[i]<L[i+1]: a,b=L[i],L[i+1] else: a,b=L[i+1],L[i] for j in range(i+2,n-1): c,d=min(L[j],L[j+1]),max(L[j],L[j+1]) 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
#include <bits/stdc++.h> using namespace std; const int OO = (int)2e9; const double eps = 1e-9; inline int stoi(string s) { stringstream ss; int x; ss << s; ss >> x; return x; } inline string itos(int s) { stringstream ss; string x; ss << s; ss >> x; return x; } int main() { int n; cin >> n; 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
import java.util.Scanner; public class C { class Circle { int left = 0; int right = 0; } public void solve() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int nums[] = 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.util.Scanner; import java.util.ArrayList; import java.util.List; public class dima1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if(n<4) { System.out.println("no"); return; } int[...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i, num[1010], x1, x2, x3, x4; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &num[i]); for (i = 0; i + 1 < n; i++) { if (num[i] < num[i + 1]) { x1 = num[i]; x2 = num[i + 1]; } else { x1 = num[i + 1]; x2 = num...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf131 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private...
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() 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)] sol = True 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 ...
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
R=range(input()-1) a=map(int,raw_input().split()) S=lambda p,q:(q,p) if p>q else (p,q) for i in R: x,y=S(a[i],a[i+1]) for j in R[i+1:]: u,v=S(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 'no'
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) l=list(map(int,input().split())) flag=0 for i in range(n): for j in range(i+1,n-1): a=l[i] b=l[i+1] c=l[j] d=l[j+1] if c>d: c,d=d,c if a>b: a,b=b,a if a<c<b<d or c<a<d<b: flag=1 break if flag==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.*; import java.util.*; import java.lang.StringBuilder; public class Solution358A { public static void main(String[] args) { //Scanner sc = new Scanner(System.in); MyScanner sc = new MyScanner(); int n = sc.nextInt(); int [] points = new int[n]; boolean reslut = false; int nowX, nowY, ...
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()) Min = -1e10 Max = 1e10 ans = "no" def f(x, y): return x[0] < y[0] and x[1] > y[0] and x[1] < y[1] or \ x[0] > y[0] and x[0] < y[1] and x[1] > y[1] xs = list(map(int, input().split())) align = [0, 0]*len(xs) align[0] = xs[0] align[1] = xs[0] for i in range(1, len(xs)): #print(align) 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
#include <bits/stdc++.h> using namespace std; int max(int a, int b) { return (a > b ? a : b); } int min(int a, int b) { return (a < b ? a : b); } int main() { int n; cin >> n; int x[n + 1]; for (int i = 1; i < n + 1; i++) { cin >> x[i]; } int flag = 0; for (int i = 2; i <= n - 1; i++) { for (int 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; const int INF = 0x3f3f3f3f; const double eps = 10e-9; const int maxn = 1000 + 20; int A[maxn]; void swap(int& a, int& b) { int c = a; a = b; b = c; } int main() { int n; scanf("%d", &(n)); for (int i = 0; i < (n); i++) scanf("%d", &(A[i])); int ans = 0; 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
import java.io.*; import java.nio.file.FileSystemNotFoundException; import java.util.*; import javax.management.loading.ClassLoaderRepository; import javax.xml.crypto.dsig.spec.HMACParameterSpec; public class A { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = 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
#include <bits/stdc++.h> using namespace std; int a[1500]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } bool ans = true; int a1, a2, b1, b2; for (int i = 0; i < n - 1 && ans; i++) { a1 = min(a[i], a[i + 1]); a2 = max(a[i], a[i + 1]); for (int j = 0; j < n - 1 ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; 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
n = [int(_) for _ in raw_input().split()] a = [int(_) for _ in raw_input().split()] b = a[:] a.sort() i = 1 while len(a) != 1: if abs(a.index(b[i-1]) - a.index(b[i])) == 1 or (b[i-1], b[i]) == (max(a), min(a)) or (b[i-1], b[i]) == (min(a), max(a)): a.remove(b[i-1]) i += 1 else: print 'ye...
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.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
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(sys.stdin.readline()) g=map(int, sys.stdin.readline().split()) for x in range(n-1): a,b=min(g[x],g[x+1]),max(g[x],g[x+1]) for y in range(n-1): c,d=min(g[y],g[y+1]),max(g[y],g[y+1]) if a<c<b<d: print 'yes' exit() print 'no' ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) k = list(map(int,input().split())) temp = 0 for i in range(len(k)-1): m = min(k[i],k[i+1]) n = max(k[i],k[i+1]) for j in range(len(k) - 1): a = min(k[j],k[j+1]) b = max(k[j],k[j+1]) if m < a < n and b >n: print('yes') temp = 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 sys,math from collections import deque,defaultdict import operator as op from functools import reduce from itertools import permutations import heapq #sys.setrecursionlimit(10**7) # OneDrive\Documents\codeforces I=sys.stdin.readline alpha="abcdefghijklmnopqrstuvwxyz" mod=10**9 + 7 """ x_move=[-1,0,1,0,-1,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
n = int(input()) a = list(map(int,input().split())) b,c,ans = [],[],0 for i in range(n-1): b.append(min(a[i],a[i+1])) c.append(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] < b[j] and c[i] > b[j] and c[j] > c[i]: ans = 1 if...
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.InputStreamReader; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.StringTokenizer; public class CodeA { static class Scanner { BufferedReader br = ne...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.awt.Point; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Enumeration; import java.util.Iterator; import...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class line { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLin...
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
import java.util.*; public class Main{ public static void main(String... args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] t = new int[n]; for (int i=0; i<n; i++){ t[i]=sc.nextInt(); for (int j=i-2; j>0; j--){ int a = Math.min(t[j],t[j-1]); int b = Math.max(t[j],t[j-1]); int aa = M...
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 xd[] = {1, 0, -1, 0}; int yd[] = {0, -1, 0, 1}; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } inline bool isEqual(double x, double y) { const double epsilon = 1e-5...
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 Main358A { public static class points { int xmin,xmax; public points(int a,int b) { if(a<b){ xmin=a; xmax=b; } else { xmin=b; xmax=a; } } } public static void main(String[] args) { Scanner ...
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() { std::ios::sync_with_stdio(false); int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) if (max(arr[i], arr[i + 1]) < max(arr[j], arr[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
#include <bits/stdc++.h> using namespace std; int main() { int n; bool flag = 0; scanf("%d", &n); if (n == 1) { printf("no\n"); return 0; } vector<int> x(n); vector<int> y(n); int p1, p2, tmp; scanf("%d%d", &p1, &p2); tmp = p2; if (p1 > p2) swap(p1, p2); x[0] = p1; y[0] = p2; for (in...
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; long long int power(long long int x, long long int y) { long long int temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return (temp * temp); else { if (y > 0) return (x * temp * temp); else return (temp * temp) / 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
# read the inputs #maintain a table of values that you have seen. # maintain the current and the next entry # for every next entry , check if any point in the hash table has that value. import sys n=int(input()) values=[int(v) for v in input().split()] # Previous solution prev=values[0] explored=[] for i in range(1,n,...
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; bool fun(int a, int b, int c, int d) { if ((a < c && c < b && b < d) || (c < a && a < d && d < b)) return true; return false; } int main() { std::ios::sync_with_stdio(false); int n, x = 0; cin >> n; bool k = false; int second[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
n=int(input()) a=list(map(int,input().split())) check=True b=[[a[i], a[i+1]] for i in range(n-1)] for i in range(n-1): b[i].sort() for j in range(i): 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]): check = False if(check): print("no") else: print(...
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, arr[1005]; bool solve() { int i, j; for (i = 0; i < n - 1; i++) { int circle1In = min(arr[i], arr[i + 1]); int circle1out = max(arr[i], arr[i + 1]); for (j = i + 1; j < n - 1; j++) { int circle2In = min(arr[j], arr[j + 1]); int circle2Out ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; public class first { static long fast_power(long a,long n,long m) { if(n==1) { return a%m; } if(n%2==1) { long power = fast_power(a,(n-1)/2,m)%m; return ((a%m) * ((power*power)%m))%m; } long power = fast_power(a,n/2,m)%m; return (power*power)%m; ...
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 Dima_and_Continuous_Line { public static void main(String[] args) { // TODO Auto-generated method stub 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(); int pre=Integer.MAX_VALUE; int post=Integ...
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; vector<int> points; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; points.push_back(tmp); } bool intersect = false; for (int i = 0; i < n - 1; i++) { 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; vector<int> s; bool flag = true; int n, x, i, j; int min(int x, int y) { return x >= y ? y : x; } int max(int x, int y) { return x >= y ? x : y; } int main() { cin >> n; for (i = 0; i < n; i++) cin >> x, s.push_back(x); for (i = 0; i < n - 1; i++) { int l1 = min(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
#include <bits/stdc++.h> using namespace std; int n, a[3030], lowi, highi, lowj, highj; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 2; i++) { lowi = min(a[i], a[i + 1]), highi = max(a[i], a[i + 1]); for (int j = i + 1; j < n - 1; j++) { int lowj = 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()) l=[int(x) for x in input().split()] l2=l[1:] a=list(zip(l,l2)) a=[sorted(i) for i in a] for i,j in a: for c,d in a: if c>i and c<j and d>j: print("yes") exit() print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class ContinuousLine2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p[] = new int[n]; for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); } boolean selfIntersec...
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 ContLine { public static void main(String[] args) { Scanner uno = new Scanner(System.in); int n = uno.nextInt(); int[] nums = new int[n]; int conf = 0; int esc = 0; int a; int b; int c; int d; for (int i = 0; i < n; i++) { nums[i] = uno.nextInt(); ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(raw_input()) x = map(int, raw_input().split()) def isCrossed(i, j): a, b = min(x[i-1], x[i]), max(x[i-1], x[i]) c, d = min(x[j-1], x[j]), max(x[j-1], x[j]) return a < c < b < d or c < a < d < b crossed = False for i in range(1, n): for j in range(1, n): if isCrossed(i, j): ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = input() a = map(int, raw_input().split()) ans = "no" for i in xrange(n-1): for j in xrange(n-1): x1, x2 = sorted([a[i], a[i+1]]) x3, x4 = sorted([a[j], a[j+1]]) if x1 < x3 < x2 and x3 < x2 < x4: ans = "yes" print ans
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
//package com.codeforces.div208; import java.io.BufferedWriter; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class DinaAndLine { /** *...
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(sys.stdin.readline()) x = [int(x) for x in sys.stdin.readline().split(" ")] pairs = [x[i]<x[i+1] and (x[i],x[i+1]) or (x[i+1],x[i]) for i in range(len(x)-1)] def check(p1,p2): if p1[0] < p2[0] and p2[0] < p1[1] and p1[1] < p2[1]: return False elif p2[0] < p1[0] and p1[0] < p2[1] an...
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.*; public class semiCircle { public static void main(String[] args) { Scanner scn=new Scanner(System.in); int n=scn.nextInt(); int[] array=new int[n]; for(int i=0;i<n;i++) { array[i]=scn.nextInt(); } boolean flag=false; boolean pg=false; int mp=0,mn=0; for(int i=1;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.util.*; import java.io.*; public class Main { static class pair implements Comparable<pair>{ int x; int y; public pair(int x, int y){ this.x=x; this.y=y; } public int compareTo(pair p){ return (x-p.x==0)?y-p.y:x-p.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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CodeForces { public static void main(String[] args) throws IOException { reader input = new reader(); PrintWriter output = new Pri...
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
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { OutputStream outputStream = System.out; FastReader in = new FastReader(); OutputWriter out = new OutputWriter(outputStream); Taska solver= new Taska(); ...
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 num; cin >> num; vector<int> tmp(num, 0); for (int i = 0; i < num; ++i) { cin >> tmp[i]; } if (num <= 2) { cout << "no"; return 0; } vector<int> s; vector<int> e; for (int i = 1; i < num; ++i) { s.push_back(min(tmp[i - 1]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << "no" << endl; return 0; } vector<pair<int, int> > arr(n - 1); cin >> arr[0].first; for (int i = 0; i < n - 1; i++) { cin >> arr[i].second; if (i + 1 < n - 1) arr[i + 1].first = arr[i].second; ...
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 ContinouosLine { static int N; static int[] points; public static boolean solve() { if (N <= 3) return false; for (int i = 3; i < points.length; i++) { int new_a = Math.min(points[i], points[i - 1]); int new_b = M...
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; long long int max(long long int a, long long int b) { if (a > b) { return a; } return b; } long long int min(long long int a, long long int b) { if (a < b) { return a; } return b; } int main() { std::ios::sync_with_stdio(false); long long int n; 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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class Solution { /** * @param args */ public static void main(String[] args) { Scanner scan = new Scanner(System.in); String line = scan.nextLine(); Scanner sc = new Scanner(line); int n = sc.nextI...
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; /** * * @author mehrdad */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=ne...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class A358 { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = new int[n]; String answer = "no"; for(int i =0;i<n;i++) a[i] = in.nextInt(); int x,y,r,s; 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
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n; 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 (x[i] < x[j + 1] && x[i] > x[j] && (x[i + 1] > 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
/* Date : Nov 13 Problem Name : Dima and Coninuous Line Location : http://codeforces.com/contest/358/problem/A Algorithm : simple Status : solving */ import java.util.*; import java.io.*; public class Main { static BufferedReader reader = 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
import sys inf = float("inf") # sys.setrecursionlimit(10000000) # abc='abcdefghijklmnopqrstuvwxyz' # abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 2...
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.*; import java.util.regex.*; import java.text.*; import java.io.PrintStream; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class A { static Scanner scan = new Scanner(Sy...
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; template <class _T> inline _T sqr(const _T& first) { return first * first; } template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795L; const double EPS = 1 - 9;...
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()) x = raw_input().split() xlen = len(x) for i in xrange(0, xlen): x[i] = int(x[i]) a = [] for i in xrange(0, n -1): s = min(x[i], x[i+1]) t = max(x[i], x[i+1]) a.append((s, t)) a.sort() #print a inter = False for i in xrange(0, n - 1): for j in xrange(i + 1, n - 1): if (a[j][0] > a[i][0]) 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.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class A implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader...
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 v[1005]; int n, i, j, stc1, drc1, stc2, drc2; cin >> n; bool rasp = 0; for (i = 1; i <= n; i++) cin >> v[i]; for (i = 2; ((i <= n) && (!rasp)); i++) for (j = i + 1; j <= n; j++) { stc1 = v[i - 1]; drc1 = v[i]; stc2 = v[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> int main() { int n; std::cin >> n; int a[n]; for (int i = 0; i < n; i++) { std::cin >> a[i]; } std::vector<std::pair<int, int>> p; for (int i = 0; i < n - 1; i++) { int x = a[i]; int y = a[i + 1]; if (x > y) { int temp = x; x = y; y = temp; } ...
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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; public class A { public static void main(String[] args) { solve(new InputReader(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
n = int(input()) a = list(map(int, input().split())) for i in range(n - 1): s = sorted((a[i], a[i + 1])) for j in range(i): lst = sorted((a[j], a[j + 1])) if lst[0] < s[0] < lst[1] < s[1] or s[0] < lst[0] < s[1] < lst[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
#include <bits/stdc++.h> using namespace std; int n; int x[2000]; vector<pair<int, int> > a; bool check(int p, int q, int z) { if (q > z) swap(q, z); if (p > q && p < z) return true; return false; } int main() { while (cin >> n) { for (int i = 0; i < n; ++i) scanf("%d", x + i); for (int i = 0; i < n - 1...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def main(): n = int(input()) l = [] a = 0 for b in map(int, input().split()): if a < b: l.append((a, b)) else: l.append((b, a)) a = b l[0] = ((0, 0)) l.sort() for i, (c, d) in enumerate(l): for j in range(i): a, b = l[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
#include <bits/stdc++.h> typedef struct cf208d2aob { int v; int n; } cf208d2aob; int cf208d2aobcmp(const void *a, const void *b) { cf208d2aob *aa = (cf208d2aob *)a; cf208d2aob *bb = (cf208d2aob *)b; if (aa->v == bb->v) return aa->n - bb->n; return ((cf208d2aob *)a)->v - ((cf208d2aob *)b)->v; } int main() { ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) a = list(map(int,input().split())) b = [] for i in range(1,n): b.append([min(a[i-1],a[i]),max(a[i-1],a[i])]) b.sort() yes = 1; for i in range(0,n-1): if(yes): for j in range(i+1,n-1): if b[j][0] >= b[i][1]: break; if b[j][1] > b[i][1] and b[j][0] > b[i][0]: # print(b[i][0],b[i][1],b[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
def solve(): n = input() A = map(int, raw_input().split()) for i in range(n-1): st_i = min(A[i], A[i+1]) end_i = max(A[i], A[i+1]) for j in range(i, n-1): st_j = min(A[j], A[j+1]) end_j = max(A[j], A[j+1]) if (st_j > st_i and st_j < end_i and end_j...
PYTHON