您的位置:首页 > 其它

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

2013-10-26 12:18 741 查看
题目链接:http://codeforces.com/contest/358/problem/A

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

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

struct Reg{
int ra, rb;
Reg(){}
void makeReg(int _ra, int _rb){
ra = min(_ra, _rb);
rb = max(_ra, _rb);
}
};

Reg R[1010];

bool judge(Reg x, Reg y)
{
if(x.ra<=y.ra && x.rb>=y.rb)return true;
if(x.ra>=y.ra && x.rb<=y.rb)return true;
if(x.ra>=y.rb || y.ra>=x.rb) return true;
return false;
}

int main()
{
//    freopen("in.txt", "r", stdin);

int a, b, n;
while(scanf("%d", &n)!=EOF)
{
scanf("%d", &a);
for(int i=1; i<n; i++){
scanf("%d", &b);
R[i].makeReg(a, b);
a = b;
}
int f = 1;
for(int i=1; i<n; i++){
for(int j=i+1; j<n; j++){
if(judge(R[i], R[j])==false){
f = 0;printf("yes\n");break;
}
}
if(f==0)break;
}
if(f) printf("no\n");
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: