[Offer收割]编程练习赛12 register

Ended

Participants:1323

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-02 14:07:32

Lang:G++

Edit
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
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
int fa[50000], n, m;
char ch[111];
int find(int x) {
    return fa[x] == x ?x : fa[x] = find(fa[x]);
}
void Union(int x, int y) {
    x = find(x), y = find(y);
    fa[x] = y;
}
int get_node(int x, int y, int k) {
    return (x * m + y) * 4 + k + 1;
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            for (int k = 0; k < 4; ++k) {
                int x = get_node(i, j, k);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX