码迷,mamicode.com
首页 > 其他好文 > 详细

0728 补题 + 题解

时间:2018-07-29 10:47:01      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:its   lap   bit   ber   div   love   size   exp   ide   

K - Robots POJ - 1548

直接暴力就可以了

技术分享图片
 1 /*
 2     Fuck you.
 3     I love you too.
 4 */
 5 
 6 //#include<bits/stdc++.h>
 7 #include<iostream>
 8 #include<cstdio>
 9 #include<cmath>
10 #include<cstring>
11 #define mem(a,x) memset(a,x,sizeof(a))
12 
13 
14 const double PI = acos (-1.0);
15 const int INF = 0x3f3f3f3f;
16 const int EXP = 1e-8;
17 const int N = 1e5 + 5;
18 const int MOD = 1e9 + 7;
19 const int MAXN = 1e5 + 5;
20 
21 using namespace std;
22 
23 int a[30][30];
24 int x, y;
25 int cnt, number, m, n;
26 int lazy;
27 
28 int main() {
29     mem (a, 0), cnt = number = m = n = 0, lazy = 1;
30     while (cin >> x >> y, x != -1 && y != -1) {
31         if (x == 0 && y == 0) {
32             while (number != 0) {
33                 lazy=1;
34                 for (int i = 1; i <= m; i++) {
35                     for (int j = lazy; j <= n; j++) {
36                         if (a[i][j] == 1) {
37                             for (int k = j; k <= n; k++) {
38                                 if (a[i][k] == 1) {
39                                     a[i][k] = 0, lazy = k, number--;
40                                     //cout << i << ‘ ‘ << k << endl;
41                                 }
42                             }
43                         }
44                     }
45                 }
46                 cnt++;
47             }
48             cout << cnt << endl;
49             mem (a, 0), cnt = number = m = n = 0, lazy = 1;
50         } else {
51             a[x][y] = 1;
52             m = max (x, m), n = max (y, n);
53             number++;
54         }
55     }
56     return 0;
57 }
View Code

 

0728 补题 + 题解

标签:its   lap   bit   ber   div   love   size   exp   ide   

原文地址:https://www.cnblogs.com/chunibyo/p/9384378.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!