**链接:****传送门 **

题意:判断 m 组数,如果某一组中出现负数就判断这一组中是否存在与之相反的数,如果每一组中都满足要求则输出 "NO" 反之输出 "YES"

思路:对于任意的一组数,if v[i] < 0 则 vector.find( v.begin() , v.end() , -v[i] )查一下在这组数中是否出现过相反数,如果 find != v.end() 说明出现过,返回 true 否则返回一个 false


/*************************************************************************
> File Name: Codeforces787B.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月25日 星期四 11时23分40秒
************************************************************************/ #include<bits/stdc++.h>
using namespace std; // #define pb(x) push_back(x) vector<int> V; bool check(){
int len = V.size();
for(int i = 0 ; i < len ; i++){
if( V[i] < 0 ){
if( find( V.begin() , V.end() , -V[i] ) != V.end() ) // 如果找到一对相反数
return true;
}
}
return false;
}
int main(){
int n , m , k , x;
bool ok = true;
scanf("%d%d",&n,&m);
for(int i = 0 ; i < m ; i++){
V.clear();
scanf("%d",&k);
for(int j = 0 ; j < k ; j++){
scanf("%d",&x); V.push_back(x);
}
if(!check()) ok = false;
}
if(ok) printf("NO\n");
else printf("YES\n");
return 0;
}

Codeforces 787B Not Afraid( 水 )的更多相关文章

  1. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  2. 【codeforces 787B】Not Afraid

    [题目链接]:http://codeforces.com/contest/787/problem/B [题意] -水题..题目太吓人 [题解] 只要你在一组里面找到两个数字,它们的绝对值相同,但是正负 ...

  3. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  4. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  5. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

  6. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

  7. CodeForces 706C Hard problem (水DP)

    题意:对于给定的n个字符串,可以花费a[i]  将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...

  8. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. Educational Codeforces Round 24 A 水 B stl C 暴力 D stl模拟 E 二分

    A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...

随机推荐

  1. oracle 工具:tkprof

    https://docs.oracle.com/cd/B10501_01/server.920/a96533/ex_plan.htm http://blog.csdn.net/dba_waterbin ...

  2. 【转】Unix下C程序内存泄漏检测工具Valgrind安装与使用

    Valgrind是一款用于内存调试.内存泄漏检测以及性能分析的软件开发工具. Valgrind的最初作者是Julian Seward,他于2006年由于在开发Valgrind上的工作获得了第二届Goo ...

  3. 在Map对象中获取属性,注意判断为空

    在Map对象中获取属性,注意判断为空 public static void main(String[] args) { Map map = new HashMap(); Integer i = (In ...

  4. Android中加入水平线和垂直线

    1.加入水平线 <View android:layout_height="0.5dip" android:background="#686868" and ...

  5. linux c 操作utmp 和 wtmp 文件接口

    /var/run/utmp 保存当前在本系统中的用户信息 /var/log/wtmp 保存登陆过本系统的用户信息 他们保存的信息是基于结构体 struct utmp 的(/usr/include/bi ...

  6. Linux 服务具体解释

    acpid ACPI(全 称 Advanced Configuration and Power Interface)服务是电源管理接口. 建议全部的笔记本用户开启它. 一些server可能不须要 ac ...

  7. oc20--继承2

    // // Phone.h #import <Foundation/Foundation.h> // 被继承的这个类我们称之为父类/ 超类 @interface Phone : NSObj ...

  8. Hdu-5992 2016ACM/ICPC亚洲区青岛站 K.Finding Hotels KDtree

    题面 题意:二维平面上有很多点,每个点有个权值,现在给你一个点(很多组),权值v,让你找到权值小于等于v的点中离这个点最近的,相同的输出id小的 题解:很裸的KDtree,但是查询的时候有2个小限制, ...

  9. Npgsql使用入门(一)【搭建环境】

    首先去官网下载最新数据库安装包 postgresql-9.6.1-1-windows-x64 将postgreSQL9.6注册为windows服务 注意:大小写要正确 D:\Worksoftware\ ...

  10. C#中的流_字节_字符_字符串之间的相互转换

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...