题意:给出一个无限大的网格图,要求你在上面涂色,每个涂色方格周围必须有偶数个涂色方格。要求构造出一种涂色方法:只存在n个涂色方格,周围有4个涂色方格(主要是理解题意)。
可以按照图像一直往下延伸。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+10;
const int inf = 0x7ffffff;
int f[][2] = {
-1, 0, 0, -1, 0, 1, 1, 0}, n, m;
int s[N];
int read() {
int x = 0; int f = 1; char s = getchar();
while(s < '0' || s > '9') {
if(s == '-') f = -1; s = getchar();}
while(s >= '0' && s <= '9') {
x = (x << 3) + (x << 1) + s - 48; s = getchar();}
return x * f;
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
int t;
t = read();
cout << 3*t + 4 << endl;
int a = 1, b = 1;
//第一个。
cout << 0 << ' ' << 0 << endl;
for(int i=0; i<2; i++) {
cout << a+f[i][0] << ' ' << b+f[i][1] << endl;
}
cout << a << ' ' << b << endl;
for(int i=2; i<4; i++) {
cout << a+f[i][0] << ' ' << b+f[i][1] << endl;
}
//后面t-1个。
for(int i=2; i<=t; i++) {
cout << i << ' ' << i << endl;
for(int j=2; j<4; j++) {
cout << i+f[j][0] << ' ' << i + f[j][1] << endl;
}
}
cout << t+1 << ' ' << t+1 << endl;
return 0;
}