Submission #9187059


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

const int N = 1010;

int n;
char c[N][N];

void NO() {
	cout << -1;
	exit(0);
}

void color(int x, int y) {
	c[x][y] = c[x][y + 1] = char('a');
	c[x][y + 2] = c[x + 1][y + 2] = char('b');
	c[x + 2][y + 1] = c[x + 2][y + 2] = char('c');
	c[x + 1][y] = c[x + 2][y] = char('d');
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	if (n == 2)
		NO();
	for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				c[i][j] = '.';
	if (n % 3 == 0) {
		for (int i = 0; i * 3 < n; i++)
			color(i * 3, i * 3);
		for (int i = 0; i < n; i++, cout << '\n')
			for (int j = 0; j < n; j++)
				cout << c[i][j];
		return 0;
	}
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			for (int k = 0; k <= 1; k++)
				if ((i * 4 + j * 5 + k * 7) == n) {
					int now = 0;
					for (int x = 0; x < i; x++) {
						c[now][now] = c[now + 1][now] = 'a';
						c[now][now + 1] = c[now + 1][now + 1] = 'b';
						c[now][now + 2] = c[now][now + 3] = 'c';
						c[now + 1][now + 2] = c[now + 1][now + 3] = 'd';
						c[now + 2][now] = c[now + 2][now + 1] = 'e';
						c[now + 2][now + 2] = c[now + 3][now + 2] = 'f';
						c[now + 2][now + 3] = c[now + 3][now + 3] = 'g';
						c[now + 3][now] = c[now + 3][now + 1] = 'h';
						now += 4;
					}
					for (int x = 0; x < j; x++) {
						c[now][now] = c[now + 1][now] = 'a';
						c[now][now + 1] = c[now + 1][now + 1] = 'b';
						c[now][now + 2] = c[now + 1][now + 2] = 'c';
						c[now + 2][now] = c[now + 3][now] = 'd';
						c[now + 2][now + 1] = c[now + 2][now + 2] = 'e';
						c[now + 2][now + 3] = c[now + 2][now + 4] = 'f';
						c[now + 3][now + 2] = c[now + 4][now + 2] = 'g';
						c[now + 3][now + 3] = c[now + 3][now + 4] = 'h';
						c[now + 4][now] = c[now + 4][now + 1] = 'i';
						c[now + 4][now + 3] = c[now + 4][now + 4] = 'j';
						now += 5;
					}
					for (int x = 0; x < k; x++) {
						c[now][now] = c[now + 1][now] = 'a';
						c[now][now + 1] = c[now + 1][now + 1] = 'b';
						c[now][now + 2] = c[now + 1][now + 2] = 'c';
						
						c[now + 2][now] = c[now + 3][now] = 'd';
						c[now + 2][now + 1] = c[now + 3][now + 1] = 'e';
						c[now + 2][now + 2] = c[now + 3][now + 2] = 'f';

						c[now + 4][now] = c[now + 5][now] = 'g';

						c[now + 4][now + 3] = c[now + 4][now + 4] = 'h';
						c[now + 4][now + 5] = c[now + 4][now + 6] = 'i';

						c[now + 5][now + 3] = c[now + 5][now + 4] = 'j';
						c[now + 5][now + 5] = c[now + 5][now + 6] = 'k';

						c[now + 6][now + 1] = c[now + 6][now + 2] = 'l';
						c[now + 6][now + 3] = c[now + 6][now + 4] = 'm';
						c[now + 6][now + 5] = c[now + 6][now + 6] = 'n';
						
						now += 7;
					}
						
					for (int x = 0; x < n; x++, cout << '\n')
						for (int y = 0; y < n; y++)
							cout << c[x][y];
					return 0;
				}
}

Submission Info

Submission Time
Task C - Domino Quality
User LODB
Language C++14 (GCC 5.4.1)
Score 900
Code Size 2913 Byte
Status AC
Exec Time 26 ms
Memory 2176 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 2
AC × 59
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt, 01-57.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 256 KiB
00-sample-02.txt AC 1 ms 256 KiB
01-01.txt AC 1 ms 256 KiB
01-02.txt AC 1 ms 256 KiB
01-03.txt AC 1 ms 256 KiB
01-04.txt AC 1 ms 256 KiB
01-05.txt AC 1 ms 256 KiB
01-06.txt AC 1 ms 256 KiB
01-07.txt AC 1 ms 256 KiB
01-08.txt AC 1 ms 256 KiB
01-09.txt AC 1 ms 256 KiB
01-10.txt AC 1 ms 256 KiB
01-11.txt AC 1 ms 256 KiB
01-12.txt AC 1 ms 256 KiB
01-13.txt AC 1 ms 256 KiB
01-14.txt AC 1 ms 256 KiB
01-15.txt AC 1 ms 256 KiB
01-16.txt AC 1 ms 256 KiB
01-17.txt AC 1 ms 256 KiB
01-18.txt AC 1 ms 256 KiB
01-19.txt AC 1 ms 256 KiB
01-20.txt AC 3 ms 640 KiB
01-21.txt AC 2 ms 384 KiB
01-22.txt AC 1 ms 256 KiB
01-23.txt AC 4 ms 640 KiB
01-24.txt AC 7 ms 896 KiB
01-25.txt AC 6 ms 896 KiB
01-26.txt AC 7 ms 896 KiB
01-27.txt AC 5 ms 768 KiB
01-28.txt AC 1 ms 384 KiB
01-29.txt AC 3 ms 640 KiB
01-30.txt AC 11 ms 1280 KiB
01-31.txt AC 13 ms 1408 KiB
01-32.txt AC 10 ms 1152 KiB
01-33.txt AC 15 ms 1408 KiB
01-34.txt AC 12 ms 1280 KiB
01-35.txt AC 16 ms 1664 KiB
01-36.txt AC 17 ms 1664 KiB
01-37.txt AC 7 ms 896 KiB
01-38.txt AC 21 ms 1920 KiB
01-39.txt AC 17 ms 1664 KiB
01-40.txt AC 19 ms 1792 KiB
01-41.txt AC 15 ms 1536 KiB
01-42.txt AC 25 ms 2176 KiB
01-43.txt AC 11 ms 1280 KiB
01-44.txt AC 22 ms 2048 KiB
01-45.txt AC 26 ms 2176 KiB
01-46.txt AC 26 ms 2176 KiB
01-47.txt AC 26 ms 2176 KiB
01-48.txt AC 26 ms 2176 KiB
01-49.txt AC 26 ms 2176 KiB
01-50.txt AC 26 ms 2176 KiB
01-51.txt AC 26 ms 2176 KiB
01-52.txt AC 26 ms 2176 KiB
01-53.txt AC 25 ms 2176 KiB
01-54.txt AC 26 ms 2176 KiB
01-55.txt AC 26 ms 2176 KiB
01-56.txt AC 26 ms 2176 KiB
01-57.txt AC 26 ms 2176 KiB