http://acm.hdu.edu.cn/showproblem.php?pid=1050
写此题写的非常不淡定。。
以至于WA了很多很多很多很多次。。明明是很简单的。 唉。
注意两点:①房间是对称分布的 ②挪桌子的房间序号的不一定是按照升序或者降序排列的。
#include <iostream>
using namespace std;
#define N 205
int room[N];
inline void swap(int &a,int &b){
int t;
t=a;
a=b;
b=t;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("1050in.txt","r",stdin);
#endif
int t,n,i,j,time;
scanf("%d",&t);
while (t--){
scanf("%d",&n);
time=0;
memset(room,0,sizeof(room));
while (n--){
scanf("%d%d",&i,&j);
if (i>j)
swap(i,j);
i=(i+1)/2;
j=(j+1)/2;
for (;i<=j;i++){
room[i]++;
if (room[i]>time)
time=room[i];
}
}
printf("%d\n",time*10);
}
return 0;
}
HDU 1050 题解
本文提供了一道HDU ACM竞赛题目1050的解答思路及代码实现,主要解决如何有效计算在不对称分布的房间中移动桌子导致的最大冲突次数的问题。
743

被折叠的 条评论
为什么被折叠?



