Codeforces Round #208 (Div. 2) Problem A Dima and Continuous Line(暴力)

题目链接:http://codeforces.com/contest/358/problem/A

纯暴力题先记录所有区间再两重循环判断即可

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 
 6 struct Reg{
 7     int ra, rb;
 8     Reg(){}
 9     void makeReg(int _ra, int _rb){
10         ra = min(_ra, _rb);
11         rb = max(_ra, _rb);
12     }
13 };
14 
15 Reg R[1010];
16 
17 bool judge(Reg x, Reg y)
18 {
19     if(x.ra<=y.ra && x.rb>=y.rb)return true;
20     if(x.ra>=y.ra && x.rb<=y.rb)return true;
21     if(x.ra>=y.rb || y.ra>=x.rb) return true;
22     return false;
23 }
24 
25 int main()
26 {
27 //    freopen("in.txt", "r", stdin);
28 
29     int a, b, n;
30     while(scanf("%d", &n)!=EOF)
31     {
32         scanf("%d", &a);
33         for(int i=1; i<n; i++){
34             scanf("%d", &b);
35             R[i].makeReg(a, b);
36             a = b;
37         }
38         int f = 1;
39         for(int i=1; i<n; i++){
40             for(int j=i+1; j<n; j++){
41                 if(judge(R[i], R[j])==false){
42                     f = 0;printf("yes\n");break;
43                 }
44             }
45             if(f==0)break;
46         }
47         if(f) printf("no\n");
48     }
49     return 0;
50 }
View Code

 

posted @ 2013-10-26 12:18  张小豪  阅读(225)  评论(0编辑  收藏  举报