zoukankan      html  css  js  c++  java
  • 【codeforces 787B】Not Afraid

    【题目链接】:http://codeforces.com/contest/787/problem/B

    【题意】

    …水题。。题目太吓人

    【题解】

    只要你在一组里面找到两个数字,它们的绝对值相同,但是正负性相反,那么就可以确定,这一组
    里面最少不会全是间谍.
    知道这个之后只要贪心一下就好;
    遇到一个组里面有互为相反数的,这个组就ok;
    如果有一个组没有,就返回false;

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define rei(x) scanf("%d",&x)
    #define rel(x) scanf("%lld",&x)
    #define ref(x) scanf("%lf",&x)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 110;
    
    int n,m;
    map <int,int> dic;
    
    void in()
    {
        rei(n),rei(m);
    }
    
    bool get_ans()
    {
        rep1(i,1,m)
        {
            int k,x;
            bool ju = false;
            rei(k);
            dic.clear();
            rep1(j,1,k)
            {
                rei(x);
                if (dic[-x])
                    ju = true;
                dic[x] = 1;
            }
            if (!ju)
                return false;
        }
        return true;
    }
    
    int main()
    {
        //freopen("F:\rush.txt","r",stdin);
        in();
        if (get_ans())
            puts("NO");
        else
            puts("YES");
        //printf("
    %.2lf sec 
    ", (double)clock() / CLOCKS_PER_SEC);
        return 0;
    }
  • 相关阅读:
    总结第十天
    总结第九天
    总结第八天
    总结第七天
    总结第六天
    总结第五天
    总结第四天
    总结第三天
    总结第二天
    每日站立会议(六)
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626531.html
Copyright © 2011-2022 走看看