您的位置:首页 > 其它

UVALive-7512-November 11th

2017-11-22 19:21 393 查看
ACM模版

描述





题解

规律题。直接看代码吧,十分好理解。

代码

#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 1111;

int T;
int r, c;
int seat[MAXN][MAXN];

int main()
{
scanf("%d", &T);

for (int ce = 1; ce <= T; ce++)
{
scanf("%d%d", &r, &c);
memset(seat, 0, sizeof(seat));

int m;
scanf("%d", &m);

int br, bc;
for (int i = 0; i < m; ++i)
{
scanf("%d%d", &br, &bc);
seat[br][bc] = 1;
}

int ans_more = 0;
int ans_less = 0;
for (int i = 0; i < r; ++i)
{
int cur = 0;
for (int j = 0; j < c; ++j)
{
if (seat[i][j] == 0)
{
++cur;
}

if (seat[i][j] == 1 || j == c - 1)
{
if (cur == 1)
{
++ans_more;
++ans_less;
}
else
{
if (cur % 2 == 0)
{
ans_more += cur / 2;
}
else
{
ans_more += cur / 2 + 1;
}

if (cur % 3)
{
ans_less += cur / 3 + 1;
}
else
{
ans_less += cur / 3;
}
}

cur = 0;
}
}
}

printf("Case #%d: %d %d\n", ce, ans_more, ans_less);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  规律