Codeforces Global Round 8 C. Even Picture(构造)
程序员文章站
2024-03-24 08:41:46
...
题意:给你一个n让你在坐标上画图,画一个连通图,他们的没个格子与相邻格子都是偶数,有n个格子是上下左右都有相邻格子。
思路:按题意去画,图画出来就好了。
这里画的是n=3的情况
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false)
#define space putchar(' ')
#define enter putchar('\n')
typedef pair<int,int> PII;
const int mod=1e4+7;
const int N=2e6+10;
const int inf=0x7f7f7f7f;
ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
return a*(b/gcd(a,b));
}
template <class T>
void read(T &x)
{
char c;
bool op = 0;
while(c = getchar(), c < '0' || c > '9')
if(c == '-')
op = 1;
x = c - '0';
while(c = getchar(), c >= '0' && c <= '9')
x = x * 10 + c - '0';
if(op)
x = -x;
}
template <class T>
void write(T x)
{
if(x < 0)
x = -x, putchar('-');
if(x >= 10)
write(x / 10);
putchar('0' + x % 10);
}
int main()
{
SIS;
int n;
read(n);
printf("%d\n",(n+1)*3+1);
printf("0 0\n");
for(int i=0;i<=n;i++)
{
printf("%d %d\n",i+1,i+1);
printf("%d %d\n",i+1,i);
printf("%d %d\n",i,i+1);
}
return 0;
}