POJ3263 Tallest Cow
程序员文章站
2022-07-12 17:51:48
...
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<utility>
using namespace std;
int a[10010], b[10010];
map<pair<int,int>,bool> existed;
int main()
{
int n, i, h, r, x, y;
cin>>n>>i>>h>>r;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
a[0] = h;
for(int i = 0; i < r; i++){
scanf("%d%d",&x,&y);
if(x > y){
swap(x,y);
}
if(existed[make_pair(x,y)]) continue;
b[x+1]--, b[y]++;
existed[make_pair(x,y)] = true;
}
for(int i = 1; i <= n; i++){
a[i] = a[i-1] + b[i];
printf("%d\n",a[i]);
}
return 0;
}
上一篇: 读《程序员修炼之道》有感
推荐阅读
-
LuoguP3069 【[USACO13JAN]牛的阵容Cow Lineup
-
poj3045 Cow Acrobats (思维,贪心)
-
POJ 3278 Catch That Cow(BFS)
-
POJ 3278 Catch That Cow 【bfs+队列】
-
最短路 Silver Cow Party
-
【洛谷】P1821 [USACO07FEB] Cow Party S(单源最短路)
-
Silver Cow Party(最短路)
-
kuangbin最短路专题Silver Cow Party (POJ - 3268)
-
kuangbin最短路专题Cow Contest POJ - 3660
-
floyd最短路径算法(poj3660 cow contest)