zoukankan      html  css  js  c++  java
  • BZOJ2530 [Poi2011]Party

    刷水凑数2333

    这题目貌似几天前applepi大爷讲过。。。直接乱搞即可,可惜当时没想出来

    每次找到两个点,如果没有它们没有边就把它们都删掉,最后必定留下一个至少n / 3的团

     1 /**************************************************************
     2     Problem: 2530
     3     User: rausen
     4     Language: C++
     5     Result: Accepted
     6     Time:3048 ms
     7     Memory:9628 kb
     8 ****************************************************************/
     9  
    10 #include <cstdio>
    11  
    12 using namespace std;
    13 const int N = 3005;
    14  
    15 int n, m;
    16 bool mp[N][N], d[N];
    17  
    18 inline int read() {
    19     int x = 0;
    20     char ch = getchar();
    21     while (ch < '0' || '9' < ch)
    22         ch = getchar();
    23     while ('0' <= ch && ch <= '9') {
    24         x = x * 10 + ch - '0';
    25         ch = getchar();
    26     }
    27     return x;
    28 }
    29  
    30 int main() {
    31   int i, j, k, x, y;
    32   n = read(), m = read();
    33   for (i = 1; i <= m; ++i) {
    34     x = read(), y = read();
    35     mp[x][y] = mp[y][x] = 1;
    36   }
    37   for (i = 1; i <= n; ++i) if (!d[i]) {
    38       for (j = 1; j <= n; ++j) if (i != j && !mp[i][j] && !d[j]) {
    39       d[i] = d[j] = 1;
    40       break;
    41       }
    42     }
    43   for (i = 1, k = 0; i <= n, k < n / 3; ++i)
    44     if (!d[i]) {
    45       printf("%d", i);
    46       if (++k == n / 3) putchar('
    ');
    47       else putchar(' ');
    48     }
    49   return 0;
    50 }
    View Code

    (p.s.  妈呀。。。这坑爹的emacs强制缩进啊。。。)

    By Xs酱~ 转载请说明 博客地址:http://www.cnblogs.com/rausen
  • 相关阅读:
    Leetcode 191.位1的个数 By Python
    反向传播的推导
    Leetcode 268.缺失数字 By Python
    Leetcode 326.3的幂 By Python
    Leetcode 28.实现strStr() By Python
    Leetcode 7.反转整数 By Python
    Leetcode 125.验证回文串 By Python
    Leetcode 1.两数之和 By Python
    Hdoj 1008.Elevator 题解
    TZOJ 车辆拥挤相互往里走
  • 原文地址:https://www.cnblogs.com/rausen/p/4204836.html
Copyright © 2011-2022 走看看