[]: https://www.acwing.com/problem/content/description/3765/

二进制矩阵

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;

int n, m;
char g[N][N];

void pL(int i, int j, int k)
{
    if (!k) printf("%d %d %d %d %d %d\n", i, j, i + 1, j, i, j + 1);
    //尖尖左上角
    else if (k == 1) printf("%d %d %d %d %d %d\n", i, j - 1, i, j, i + 1, j);
    //尖尖右上角
    else if (k == 2) printf("%d %d %d %d %d %d\n", i - 1, j, i, j, i, j - 1);
    //尖尖右下角
    else printf("%d %d %d %d %d %d\n", i - 1, j, i, j, i, j + 1);
    //尖尖左下角
}

int main()
{
    int T;
    cin >> T;
    while (T -- )
    {
        cin >> n >> m;
        int res = 0;
        for (int i = 1; i <= n; i ++ )
        {
            cin >> g[i] + 1;
            for (int j = 1; j <= m; j ++ )
                if (g[i][j] == '1')
                    res += 3;
        }
        cout << res << endl;
        for (int i = 1; i <= n; i ++ )
            for (int j = 1; j <= m; j ++ )
                if (g[i][j] == '1')
                {
                    if (i < n && j < m)
                        pL(i, j, 0), pL(i, j + 1, 1), pL(i + 1, j, 3);
                    else if (i == n && j == m)
                        pL(i, j, 2), pL(i - 1, j, 1), pL(i, j - 1, 3);
                    else if (i == n)
                        pL(i, j, 3), pL(i - 1, j, 0), pL(i, j + 1, 2);
                    else
                        pL(i, j, 1), pL(i, j - 1, 0), pL(i + 1, j, 2);
                }
    }
    return 0;
}

数字矩阵

三元数异或

兔子跳

亮灯时长

数组补全

战舰

质数问题

解码

构造字符串

幸运年份