CodeForces - 1368C Even Picture

构造题,如下图所示
CodeForces - 1368C Even Picture_第1张图片

#include
#define ll long long
#define inf 0x3f3f3f3f
#define ms(x,a) memset(x,a,sizeof(x))
using namespace std;
const int maxn = 1e3 + 10;
const ll mod = 1e9 + 7;
int n;
char G[maxn][maxn];
bool v[maxn][maxn];
int dx[] = {0,1,-1,0,0},dy[] = {0,0,0,1,-1};

int main() {
	ms(G,'0');
	ms(v,0);
	scanf("%d",&n)
	int ans = 0;
	for(int i = 1;i <= n;i++){
		G[i][i] = '1';
	}
	for(int i = 1; i <= 1000; i++) {
		for(int j = 1; j <= 1000; j++) {
			if(G[i][j] == '1') {
				v[i][j] = 1;
				ans++;
				for(int k = 1; k <= 4; k++) {
					int xx = i + dx[k],yy = j + dy[k];
					if(!v[xx][yy] && G[xx][yy] == '0') {
						v[xx][yy] = 1;
						ans++;
					}
				}
			}
		}
	}
	cout<<ans + 2<<endl;
	v[0][0] = 1;
	v[n + 1][n + 1] = 1;
	for(int i = 0;i <= 1000;i++){
		for(int j = 0;j <= 1000;j++){
			if(v[i][j]){
				cout<<i<<" "<<j<<endl;
			}
		}
	}
	return 0;
}


 

你可能感兴趣的:(codeforces,acm竞赛)