zoukankan      html  css  js  c++  java
  • 1487: 未覆盖顶点数量.

    有N个顶点,每个顶点有一个权值,初始值皆为0。接下来有M次操作,操作内容为 [a,b) or [b,a),将区间内顶点i 权值置为1,求最后顶点权值为0的数量。

     1 #include <stdio.h>
     2 #include <string.h>
     3 int main()
     4 {
     5     int n,m,a,b,i;
     6     int f[50010];
     7     while (~scanf("%d%d",&n,&m))
     8     {
     9         memset(f,0,sizeof(f));
    10         for (i=1;i<=m;i++)
    11         {
    12             scanf("%d%d",&a,&b);
    13             if (a>b)
    14             {
    15                 int t=a;
    16                 a=b;
    17                 b=t;
    18             }
    19             f[a]+=1;
    20             f[b]-=1;
    21         }
    22         int s=0,num=0;
    23         for (i=1;i<=n;i++)
    24         {
    25             s+=f[i];
    26             if (s==0)
    27             num++;
    28         }
    29         printf("%d\n",num);
    30     }
    31     return 0;
    32 }
    当你试图了解你的祖国时,你已踏上了犯罪的路程。
  • 相关阅读:
    git的版本回退
    elementui的表格有多选框时翻页记住之前选择的数据
    git操作总结
    POJ 3107 Godfather
    HDU 4405 Aeroplane chess
    ZOJ 3626 Treasure Hunt I
    UVA 10537 Toll! Revisited
    POJ 3093 Margaritas on the River Walk
    POJ 1655 Balancing Act
    POJ 2342 Anniversary party
  • 原文地址:https://www.cnblogs.com/modiz/p/3017104.html
Copyright © 2011-2022 走看看