zoukankan      html  css  js  c++  java
  • 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
    ");break;
    43                 }
    44             }
    45             if(f==0)break;
    46         }
    47         if(f) printf("no
    ");
    48     }
    49     return 0;
    50 }
    View Code
    奔跑吧!少年!趁着你还年轻
  • 相关阅读:
    PHP CI分页类带多个参数
    PHP oracle分页
    PHP 防范IP攻击
    PHP 防范CC攻击
    PHP 防范xss攻击
    html input
    弹框样式
    php最快捷的插入数据,3000万仅需5秒
    phpcms 后台分页
    phpcms 用phpexcel导入导出excel
  • 原文地址:https://www.cnblogs.com/shu-xiaohao/p/3389184.html
Copyright © 2011-2022 走看看