思路:心态大崩,最多不讲了,最少应该是三个一组,比如......应该是.S..S.,这样占的最多
代码:
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn = + ;
const int MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
int row[maxn][maxn], cnt[maxn];
int getMax(int s){
return (s + ) / ;
}
int getMin(int s){
if(s % == ){
return s / ;
}
else if(s % == ){
return (s + ) / ;
}
else return (s + ) / ;
}
int main(){
int t, ca = ;
scanf("%d", &t);
while(t--){
int b, r, s;
scanf("%d%d", &r, &s);
scanf("%d", &b);
memset(cnt, ,sizeof(cnt));
for(int i = ; i <= b; i++){
int x, y;
scanf("%d%d", &x, &y);
row[x][cnt[x]++] = y;
}
int Max = , Min = ;
for(int i = ; i < r; i++){
if(cnt[i] == ){
Max += getMax(s);
Min += getMin(s);
}
else{
sort(row[i], row[i] + cnt[i]);
for(int j = ; j < cnt[i]; j++){
if(j == ){
int tmp = row[i][j] - ;
Max += getMax(tmp);
Min += getMin(tmp);
}
else{
int tmp = row[i][j] - row[i][j - ] - ;
Max += getMax(tmp);
Min += getMin(tmp);
}
}
int tmp = s - - row[i][cnt[i] - ];
Max += getMax(tmp);
Min += getMin(tmp);
}
}
printf("Case #%d: %d %d\n", ca++, Max, Min);
}
return ;
}
/*
3
2 3
1
0 1
2 3
0
1 1
1
0 0
*/