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; }
相关文章推荐
- ECfinal UVALive 7512 November 11th (公式)
- UVALive 7512 November 11th(脑洞)
- UVaLive 7512 November 11th (思维漏洞)
- UVALive 7512 November 11th
- UVALive 7512 November 11th
- UVALive 7512 November 11th(模拟, 思维)
- November 11th UVALive - 7512
- UVALive 7512 November 11th
- UVA7512 November 11th (思路)
- UVALive 7512
- UVALive 6198 A Terribly Grimm Problem
- UVALive - 3213 Ancient Cipher ( 思维 )
- uvalive4015 (树上背包)
- uva10716 - - Evil Straw Warts Live
- UVALive-4793 Robots on Ice 搜索加剪枝
- UVALive 3953 Strange Billboard (状态压缩+枚举)
- UVALIVE 4819 最大流
- uvalive 6693 - Flow Game - BFS
- UVaLive 6697 Homework Evaluation (DP)
- UVALive 3977