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;
struct circle {
int x;
int d;
} c[1005];
int main() {
int i, j, flag, n, a[1005];
scanf("%d", &n);
flag = 0;
for (i = 0; i < n; ++i) scanf("%d", &a[i]);
for (i = 0; i < n - 1; ++i) {
c[i].x = min(a[i], a[i + 1]);
c[i].d = abs(a[i + 1] - a[i]);
}
fo... | 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.*;
import java.util.StringTokenizer;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
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 | from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
def solver():
n = input()
num = map(int,raw_input().split())... | 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 a[1005];
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (int i = 2; i <= n; i++) {
for (int j = 2; j <= n; j++) {
if (i == j) continue;
int x1 = a[i - 1];
int y1 = a[i];
int x2 = 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 | #include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void solve() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n - 1; i++) {
for (int j = 1 + i; j < n - 1; j++) {
int p = a[i], q = a[i + 1], r = a[j], s = a[j + 1];
if (p > q) swap(p, q);... | 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 DimaAndContinuousLine {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(f.readLine());
StringTokenizer st = new StringTokenizer(f.... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.io.*;
import java.util.*;
public class Semicircles {
public static void main(String[] args) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(rd.readLine());
x = new int[n];
st = new StringTokenizer(rd.read... | 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.Arrays;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
boolean yes = false;
for (int i = 0; i < n && !yes; i++) {
a[i] = in.nextInt... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | n = int(raw_input())
a = map(int, raw_input().split())
ok = True
b = [[a[i], a[i+1]] for i in xrange(n-1)]
for i in xrange(n-1):
b[i].sort()
for j in xrange(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]:
ok = False
print "no" if ok else "yes"
| PYTHON |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | n=int(input())
l=list(map(int,input().split()))
l1=[]
for i in range(n-1):
l1+=[[l[i],l[i+1]]]
for i in range(n-1):
if l1[i][0]>l1[i][1]:
l1[i][0],l1[i][1]=l1[i][1],l1[i][0]
for i in l1:
for j in l1:
if i[0]<j[0]<i[1]<j[1]:
print("yes")
exit()
elif j[0]<i[0]<j[1]<i[1]:
print("yes")
exit()
print("no... | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | n,ans = int(raw_input()),"no"
x = list(int(y) for y in raw_input().split())
for i in xrange(0,n-1):
for j in xrange(0,i):
l,r = sorted([x[i],x[i+1]])
L,R = sorted([x[j],x[j+1]])
if l>L and l<R and r>R : ans = "yes"
elif r>L and r<R and l<L : 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 | a=int(input())
z=[]
te=list(map(int,input().split()))
for i in range(1,len(te)):
z.append([min(te[i],te[i-1]),max(te[i],te[i-1])])
flag=0
for i in range(len(z)):
for j in range(i+1,len(z)):
if(z[j][0]<z[i][0]<z[j][1] and z[i][1]>z[j][1]):
flag=1
break;
if(z[i][0]<z[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, now, prev;
vector<pair<int, int> > e;
cin >> n >> prev;
for (int i = 1; i < n; ++i) {
cin >> now;
e.push_back(pair<int, int>(min(prev, now), max(prev, now)));
prev = now;
}
sort(e.begin(), e.end());
for (unsigned i = 0; i < e.si... | 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::sync_with_stdio(false);
vector<int> store;
int n;
cin >> n;
for (int k = 0; k < n; k++) {
int curr;
cin >> curr;
store.push_back(curr);
}
vector<pair<int, int>> pairs;
for (int k = 0; k < store.size() - 1; k++)
pairs.push_ba... | 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.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using... | 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;
bool intersectan(int a, int b, int c, int d) {
if (a > b) swap(a, b);
if (c > d) swap(c, d);
if ((a < c && c < b && b < d) || (c < a && a < d && d < b)) {
return true;
}
return false;
}
int main() {
int n;
bool e = false;
cin >> n;
vector<int> x(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()
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 | #include <bits/stdc++.h>
using namespace std;
int cmp(vector<int> x, vector<int> y) { return x[0] < y[0]; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(3));
multiset<pair<int, int>> stl, str;
int prev;
cin >>... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.util.*;
import java.io.*;
import java.util.Scanner;
public class luckydivision {
public static void main(String args[]){
Scanner inp = new Scanner(System.in);
int n = inp.nextInt();
int arr[] = new int[n];
for(int i=0;i<n;++i){
arr[i] = inp.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 | ######################################################################
# Write your code here
import sys
from math import *
input = sys.stdin.readline
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])
#sys.setrecursionlimit(0x100000)
# Write your code here
RI = lambda : [... | PYTHON |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int, int> > v;
vector<int> num;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
num.push_back(a);
if (i > 0) {
int b = num[i - 1];
v.push_back(make_pair(min(a, b), max(a, b)));
}
}
for (i... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class DimaAndContinuousLine {
void run() throws Exception {
BufferedReader bfd = new BufferedReader(
new InputStreamReader(System.in));
int n = Integer.p... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[1111];
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++)
for (int j = i + 1; j + 1 < n; j++) {
int u = min(a[i], a[i + 1]), v = max(a[i], a[i + 1]);
int uu = min(a[j], a[j + 1]), vv = max(a[j], 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 | #include <bits/stdc++.h>
typedef struct node {
int data;
struct node *next;
} linklist;
linklist *last;
linklist *InitList() {
linklist *L;
L = (linklist *)malloc(sizeof(linklist));
L->next = L;
return L;
}
int InsSortItem(linklist *L, int item) {
int j;
linklist *p, *t;
p = L;
j = 1;
t = (linklis... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import sys
import math
import itertools
import collections
def divs(n, start=2):
r = []
for i in range(start, int(math.sqrt(n) + 1)):
if (n % i == 0):
if (n / i == i):
r.append(i)
else:
r.extend([i, n // i])
return r
def cdiv(n, k): return 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 |
import java.io.*;
import java.util.StringTokenizer;
public class A implements Runnable {
PrintWriter out;
BufferedReader br;
StringTokenizer st;
public static void main(String[] args) throws IOException {
new Thread(new A()).start();
}
public String next() throws IOException {
... | 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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class Main
{
public static void main(String args[]) throws 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 = int(raw_input())
l = map(int,raw_input().split())
def check(i,j):
a,b = min(l[i],l[i+1]),max(l[i],l[i+1])
c,d = min(l[j],l[j+1]),max(l[j],l[j+1])
return (a < c and c < b and b < d) or (c < a and a<d and d < b)
ans = "no"
for i in xrange(n-1):
for j in xrange(i+1,n-1):
if check(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 | import java.util.Scanner;
import java.lang.*;
import static java.lang.Integer.max;
import static java.lang.Integer.min;
public class DimaandContinuousLine {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
boo... | 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())
ans = "no"
f = lambda x, y: 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 = "yes"
break
print(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 | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g;
int n, m[100000], a, b;
bool check(int x11, int x12, int x21, int x22) {
if (x21 < x12 && x22 > x12 && x11 < x21 ||
x21 < x11 && x22 > x11 && x12 > x22)
return true;
else
return false;
}
int main() {
scanf("%d", &n);
scanf("%... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 |
n = int(input())
x = list(map(int, input().split()))
x = [sorted(x[i:i+2]) for i in range(n-1)]
for c,d in x:
for a,b in x:
if a < c < b <d:
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;
template <class T>
T sq(T n) {
return n * n;
}
template <class T>
T getabs(T n) {
return n < 0 ? -n : n;
}
template <class T>
T getmax(T a, T b) {
return (a > b ? a : b);
}
template <class T>
T getmin(T a, T b) {
return (a < b ? a : b);
}
template <class T>
void set... | 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()):
l.append((a, b) if a < b else(b, a))
a = b
l[0] = ((9999999, 0))
l.sort()
del l[-1]
for i, (c, d) in enumerate(l):
for j in range(i):
a, b = l[j]
if a < c < b < d:
... | 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=[int(x) for x in input().split()]
for i in range(n-1):
Main=[A[i],A[i+1]]
Main.sort()
for j in range(i+1,n-1):
SubMain=[A[j],A[j+1]]
SubMain.sort()
NewList=[Main,SubMain]
NewList.sort()
if NewList[0][0]==NewList[1][0]:
continue
elif NewList[0][1]>NewList[1][0] and Ne... | 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;
int a[1015];
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int intersec = 0;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n && abs(i - j) > 1; j++) {
int A = min(a[i], a[i + 1]), B = max(a[i], a[i + 1]);
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())
points = list(map(int,input().split(" ")))
segments = []
for i in range(len(points)):
if i != len(points) - 1:
segments.append((points[i],points[i+1]))
r = "no"
for seg1 in segments:
for seg2 in segments:
if seg1==seg2:
continue
x1,x2,x3,x4 = (min(seg1),ma... | 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.Arrays;
import java.util.StringTokenizer;
public class A {
//IO
static BufferedReader f;
static PrintWriter out;
static StringTokenizer st;
final public static void main( S... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<long int> v;
int main() {
int i, j, n;
cin >> n;
long int k;
for (i = 0; i < n; i++) {
cin >> k;
v.push_back(k);
}
long int a, b;
int q = 0;
for (i = 0; i < v.size() - 1; i++) {
b = max(v[i], v[i + 1]);
a = min(v[i], v[i + 1]);
for... | 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()]
found = False
if n<4:
print("no")
else:
for i in range(n-2):
a= min(l[i], l[i+1])
b= max(l[i], l[i+1])
for j in range(i+1, n-1, 1):
c=min(l[j], l[j+1])
d=max... | 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 = [int(x) for x in input().split()]
p = x[0]
l = []
for i in range(1, n):
for a, b in l[:-1]:
if (a < x[i] < b) ^ (a < p < b):
print('yes')
exit()
l.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 |
N = int(input())
array = list(map(int, input().split()))
points = []
for i in range(N - 1):
points.append(sorted((array[i], array[i+1])))
#print(points)
for i in points:
for j in points:
if i[0] < j[0] and j[1] > i[1] > j[0]:
#print(i, j)
print("yes")
exit(0)
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 | import java.util.Arrays;
import java.util.Scanner;
public class Young {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int tab[] = new int[n];
boolean res = false;
for(int i =0; i<n; i++)
{
tab[i] = sc.nextInt();
}
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
int n;
cin >> n;
long long A[n];
for (int i = 0; i < n; i++) {
cin >> A[i];
}
if (n == 1) {
cout << "no";
return 0;
}
for (int i = 1; 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 | /*input
1
0
*/
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static PrintWriter out;
static int MOD = 1000000007;
static FastReader scan;
/*-------- I/O using short named function ---------*/
public static String ns(){return scan.next();}
public static int ni(){return scan.nex... | 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 | length = int(input())
sequence = list(map(int, input().split()))
if length <= 3:
print('no')
else:
for i in range(length - 1):
w, x = sorted([sequence[i], sequence[i + 1]])
for j in range(length - 1):
y, z = sorted([sequence[j], sequence[j + 1]])
if w < y < x < z or y < w... | 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())
l=list(map(int,input().split()))
for i in range(1,n) :
for j in range(i,0,-1) :
x,x1=max(l[i],l[i-1]),min(l[i],l[i-1])
y,y1=max(l[j],l[j-1]),min(l[j],l[j-1])
if x1>y1 and x1<y and x>y or x1<y1 and y1<x and x<y :
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;
void swap(int *a, int *b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int main() {
int n;
cin >> n;
int x1, x2, x3, x4;
int array[n];
int i = 0, j = 0;
for (i = 0; i < n; i += 1) cin >> array[i];
bool ans = false;
for (i = 0; i < n; i += 1) {
if... | 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.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StreamCorruptedException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java... | 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())
inp = input().split()
x = [int(p) for p in inp]
for i in range(0,n-2):
for j in range(i+1,n-1):
# (i,i+1) vs. (j,j+1)
al = min(x[i],x[i+1])
ar = max(x[i],x[i+1])
#print(i,j,al,ar,x[j],x[j+1])
ins1 = al<x[j] and x[j]<ar and (x[j+1]<al or x[j+1]>ar)... | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int betw(int z, int x, int y) { return z < max(x, y) && z > min(x, y); }
int main() {
int a[1010], n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
bool flag = false;
for (int i = 1; i < n; i++)
for (int j = 1; j < n; j++) {
if (a[j] == a[i] || 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 = list(map(int, input().split()))
result = True
for i in range(n-2):
li, ri = min(l[i], l[i+1]), max(l[i], l[i+1])
for j in range(i+2, n-1):
lj, rj = min(l[j], l[j+1]), max(l[j], l[j+1])
if (li < lj < ri and not(li < rj < ri)) or (li < rj < ri and not(li < lj < ri)):
... | 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 | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
/**
* @author Assassin
*/
public class A {
private BufferedReader reader;
private PrintWriter out;
private StringTokenizer tokenizer;
//private final String file... | 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;
if (n <= 2) {
cout << "no";
return 0;
}
vector<pair<int, int>> z;
int a, b, c;
cin >> a;
cin >> b;
for (int i = 0; i < n - 2; i++) {
cin >> c;
for (int j = 0; j < z.size(); j++) {
if (c >= z[j].first && 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;
const int maxN = 1e3 + 100;
int a[maxN];
bool intersect(int a2, int a1, int b2, int b1) {
if (b1 > a1 && b1 < a2) {
if (b2 > a2 || b2 < a1)
return true;
else
return false;
} else if (b2 > a1 && b2 < a2) {
if (b1 < a1 || b1 > a2)
return true... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
Outpu... | 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())
l=list(map(int,input().split()))
if n<4:
print("no")
else:
prev=l[1]
ans="no"
for i in range(2,n):
for j in range(1,n):
if min(l[j],l[j-1])<min(prev,l[i])<max(l[j],l[j-1]) and max(l[i],prev)>max(l[j],l[j-1]):
ans="yes"
break
... | 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 long long N = 1e3 + 5;
long long n;
long long x[N];
map<long long, long long> last;
bool intersect(long long a, long long b, long long c, long long d) {
vector<pair<long long, long long> > v;
v.push_back({a, 1});
v.push_back({b, 1});
v.push_back({c, 2});
v.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 | #include <bits/stdc++.h>
using namespace std;
int between(int a, int b, int c) { return a > b and a < c; }
int main() {
int n, X[1001];
vector<pair<int, int> > v;
cin >> n;
for (int i = 0; i < n; i++) cin >> X[i];
if (n == 1)
cout << "no\n";
else {
int last = X[0];
for (int i = 1; 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;
vector<pair<int, int> > v;
vector<int> points;
int main() {
int n, e;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> e;
points.push_back(e);
}
for (int i = 1; i < n; ++i) {
if (points[i - 1] < points[i])
v.push_back(pair<int, int>(points[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 = raw_input()
n = int(n)
s = raw_input()
ss = s.split(' ')
for i in xrange(len(ss)):
ss[i] = int(ss[i])
if len(ss) <= 2:
print 'no'
else :
lst = []
#print ss
for i in xrange(len(ss) - 1):
#print i
if ss[i] < ss[i + 1]:
lst.append((ss[i], ss[i + 1],))
else :
lst.append((ss[i+1], ss[i],))
ret = False... | PYTHON |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | //package c208;
import java.util.Scanner;
public class q1
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int a[]=new int[n];
boolean ans=false;
for(int i=0;i<n;i++)
{
a[i]=s.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(input())
pre = 999999
segs = []
for x in map(int, input().split()):
if pre != 999999:
segs.append((min(pre, x), max(pre, x)))
pre = x
segs.sort()
intersect = False
for i in range(0, len(segs)):
for j in range(i, len(segs)):
if segs[i][0] < segs[j][0] < segs[i][1] < segs[j][1]:
... | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.util.*;import java.io.*;import java.math.*;
public class Dima
{
public static void process()throws IOException
{
int n=ni();
int[]A=nai(n);
if(n<4)
{
pn("no");
return;
}
for(int i=3;i<n;i++)
{
for(int j=0;j<i... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, a1, a2, b1, b2;
int a[1005];
bool check(int i, int j) {
a1 = a[i];
b1 = a[i + 1];
a2 = a[j];
b2 = a[j + 1];
if (a1 > b1) swap(a1, b1);
if (a2 > b2) swap(a2, b2);
if ((a1 > a2 && a1 < b2 && b1 > b2) || (a1 < a2 && b1 > a2 && b1 < b2))
return 1;
els... | 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 Intersect(aa,bb,xx,yy):
a=min(aa,bb)
b=max(aa,bb)
x=min(xx,yy)
y=max(xx,yy)
if(a>=x and b<=y):
return False
if(x>=a and y<=b):
return False
if(b<=x):
return False
if(y<=a):
return False
return True
N=int(input())
case=False
L=list(map(int,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 | n = int(input())
arr = list(map(int, input().split()))
flag = 0
for i in range(n-1):
for j in range(i+1,n-1):
a,b = min(arr[i],arr[i+1]),max(arr[i],arr[i+1])
c,d = min(arr[j],arr[j+1]),max(arr[j],arr[j+1])
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.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
public static void main(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 = input()
a = map(int,raw_input().split())
ans = "no"
for i in range(n-1):
for j in range(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 | import sys
import fractions
a = sys.stdin.readline()
n = int(a)
a = sys.stdin.readline()
a = a.strip().split()
a = [int(i) for i in a]
def isInter(c1, c2):
if c1[0] > c2[0] and c1[0] < c2[1] and c1[1] > c2[1]:
return True
if c1[1] > c2[0] and c1[1] < c2[1] and c1[0] < c2[0]:
return True
ret... | PYTHON |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | # your code goes here
n = input()
arr = map(int, raw_input().split())
i = 0
t = True
while i<n-1:
j = 0
while j<n-1:
a = arr[i]
b = arr[i+1]
c = arr[j]
d = arr[j+1]
if a>b:
a,b = b,a
if c>d:
c,d = d,c
if a<c<b<d:
t = Fal... | PYTHON |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | import java.io.*;
import java.util.*;
public class Test {
static FastScanner sc;
static boolean[] visited;
static int four = 0, seven = 0;
public static void main(String args[]) {
sc = new FastScanner(System.in);
solve();
}
public static void solve() {
int n = sc.nextInt();
int[] arr = new int[n];
f... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 |
import java.util.LinkedList;
import java.util.Scanner;
public class A_Line {
static class Line {
int a, b;
Line(int a, int b) {
this.a = a;
this.b = b;
}
public String toString() {
return "[" + a + "," + b + "]";
}
boolean intersect(Line l) {
int x0, y0, x1, y1;
x0 = a < b ? a : b;
y... | 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> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
string res = "no";
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
if (i != j) {
int x1 = min(a[i], a[i + 1]);
int x2 = max(a[i... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n;
scanf("%d", &n);
long *Coordinates;
Coordinates = (long *)malloc((n + 1) * sizeof(int));
int i;
for (i = 0; i < n; i++) {
scanf("%ld", &Coordinates[i]);
}
int num = n;
long *x, *y;
x = (long *)malloc(num * sizeof(int));
y = (long *)malloc(num * size... | 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.ArrayList;
public class ContinuousLine {
public static class Intervalo{
public int min;
public int max;
public Intervalo (int num1, int num2){
min = Integer.min(num1, num2);
max = Integer.ma... | JAVA |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int input[1010];
struct node {
int start;
int end;
node(){};
node(int _start, int _end) {
start = _start;
end = _end;
}
} nodes[1000];
int main() {
int n;
while (cin >> n) {
bool flag = false;
int xi = 0;
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 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] arr = new int[n];
for (int j = 0; j < n; ++j) arr[j] = s.nextInt();
String out = "no";
for (int k = 1; k < n; ++k) {
for (int l = k + 1; l... | 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.setrecursionlimit(100000)
n = int(sys.stdin.readline().strip())
arr = [int(x) for x in sys.stdin.readline().strip().split()]
pair = [(min(arr[x],arr[x+1]),max(arr[x],arr[x+1]))
for x in range(0,n-1)]
flag = False
for i in range(0,n-2):
p = pair[i]
for j in range(i+1,n-1):
k = pair[j]
if p[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 | import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] array= new int[N];
for(int a=0;a<N;a++)array[a]=sc.nextInt();
boolean OK = true;
for(int a=0;a<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;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ma = max(a[0], a[1]);
ma = max(a[2], ma);
int mi = min(a[0], a[1]);
mi = min(a[2], mi);
for (int i = 3; i < n; i++) {
ma = max(a[i], ma);
mi = min(a[i], ... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
int num[1005];
using namespace std;
int judge(int x1, int x2, int x3, int x4) {
if (x1 > x2) swap(x1, x2);
if (x3 > x4) swap(x3, x4);
if (x1 < x3 && x3 < x2 && x2 < x4) return (1);
if (x3 < x1 && x1 < x4 && x4 < x2) return (1);
return (0);
}
int main() {
int n;
scanf("%d", &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=int(input())
l1=list(map(int,input().split()))
pairs=[]
for i in range(n-1):
pairs.append((min(l1[i],l1[i+1]),max(l1[i],l1[i+1])))
flag=0
for i in range(n-1):
for j in range(i+1,n-1):
if pairs[i][0]>pairs[j][0] and pairs[i][0]<pairs[j][1] and pairs[i][1]>pairs[j][1]:
flag=1
bre... | 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 |
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""
n=int(input())
a=list(map(int,input().split()))
p=[]
for i in range(n-1):
p.append([min(a[i],a[i+1]),max(a[i],a[i+1])])
for i in p:
for j in p:
if i[0]<j[0]<i[1]<j[1] or j[0]<i[0]<j[1]<i[1]:
print("yes")
exit()
print("no") | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int num[1211];
inline bool cross(int a, int b) {
int x0 = num[a];
int x1 = num[a + 1];
int y0 = num[b];
int y1 = num[b + 1];
if (x0 > x1) swap(x0, x1);
if (y0 > y1) swap(y0, y1);
if (x0 < y0 && x1 > y0 && x1 < y1) return true;
if (x0 > y0 && x0 < y1 && x1 > ... | 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,c,ok=[],[],1
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]):ok=0
if(ok):print('no')
else:print('yes') | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int xs[1000];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
cin >> xs[i];
}
bool ok = 1;
for (int i = 0; i < n - 1; ++i) {
int st = min(xs[i], xs[i + 1]);
int ed = max(xs[i], xs[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 n, p[1005];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", p + i);
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n - 1; j++) {
int a = min(p[i], p[i + 1]);
int b = max(p[i], p[i + 1]);
int c = min(p[j], p[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())
arr=list(map(int , input().split()))
l=[]
for i in range(1,n):
m1=min(arr[i],arr[i-1])
m2=max(arr[i],arr[i-1])
l.append((m1,m2))
flag=0
for i in range(1,n-1):
lb=l[i][0]
ub=l[i][1]
for j in range(0,i):
if(lb>=l[j][0] and ub<=l[j][1]):
continue
if(ub<... | 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())
l= list(map(int, input().split()))
ans='no'
for i in range(0, n-1):
for j in range(0, n-1):
x1,x2= sorted([l[i], l[i+1]])
x3,x4= sorted([l[j], l[j+1]])
if x1<x3<x2 and x3<x2<x4:
ans='yes'
print(ans) | PYTHON3 |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int t[1003];
for (int i = 0; i < n; i++) {
cin >> t[i];
}
for (int i = 1; i < n - 1; i++) {
for (int j = i; j < n - 1; j++) {
int x = min(t[j], t[j + 1]), y = max(t[j], t[j + 1]);
int a = min(t[i - 1], t[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 main() {
int n;
cin >> n;
if (n == 1 || n == 2 || n == 3) {
cout << "no";
return 0;
}
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++)
if (max(a[i], a[i + 1]) < max(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())
x = [int(i) for i in input().split()]
if (n < 3):
print ('no')
else:
ans = 'no'
for i in range(3, n):
prev = x[i - 1]
num = x[i]
for j in range(i - 2):
num1 = min(x[j], x[j + 1])
num2 = max(x[j], x[j + 1])
if (prev < num1 or prev ... | 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.Locale;
import java.util.StringTokenizer;
public class Solution_A implements Runnable {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tokenizer;
public static void main(String[] args) {
new Thread(null, new Solution_A(), "", 256 *... | 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 maxn = 1010;
int x[maxn];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> x[i];
int flag = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n - 1; j++) {
int t1 = min(x[i], x[i + 1]);
int t2 = max(x[i], 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 | #include <bits/stdc++.h>
using namespace std;
const int max_n = 1e3;
int n;
int cor[max_n + 1];
void input() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> cor[i];
}
}
bool check(int l1, int r1, int l2, int r2) {
if (l1 == l2 && r1 == r2) return true;
if (l2 > l1 && l2 < r1 && r2 > r1) return true;
if... | 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 Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // <= 10^3
int[] val = new int[n];
for (int i = 0; i < n; i++) val[i] = sc.nextInt();
String result = "no";
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 | #include <bits/stdc++.h>
using namespace std;
int n, m;
map<string, int> mpp;
vector<vector<pair<int, int> > > AdjList;
vector<int> visited;
priority_queue<pair<int, int> > pq;
int main() {
ios_base::sync_with_stdio(false);
int n;
int temp;
cin >> n;
int a[10000];
for (int i = 0; i < n; i++) cin >> a[i];
... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
void bs_b8a() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const long long mod = 1e9 + 7;
long long arr[N];
using namespace std;
int main() {
bs_b8a();
long long ta = 1;
while (ta--) {
long long n;
cin >> n;
for (int i... | CPP |
358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 2 | 7 | n = int(input())
points = map(int, raw_input().split())
def getKey(x) :
return x[0]
if n <= 2 :
print "no"
else :
intervals = []
for i in range(1, len(points)) :
a = min(points[i], points[i-1])
b = max(points[i], points[i-1])
intervals.append([a, b])
intervals.sort(key=getKey)
# print intervals
flag ... | PYTHON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.