QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#320442#8217. King's Dinnerucup-team1303#WA 2ms3604kbC++203.1kb2024-02-03 16:52:472024-02-03 16:52:47

Judging History

你现在查看的是最新测评结果

  • [2024-02-03 16:52:47]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3604kb
  • [2024-02-03 16:52:47]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T &x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 110;
int n;
char a[N][N];
bool check1(int x, int y) {
	if (x == n) return false;
	F(i, max(1, x - 1), min(n, x + 2))
		F(j, max(1, y - 1), min(n, y + 1))
			if (a[i][j] == '#') return false;
	// if (a[x][y] == '#') return false;
	// if (a[x + 1][y] == '#') return false;
	// if (y > 1 && a[x - 1][y - 1] == '#') return false;
	// if (y > 1 && a[x][y - 1] == '#') return false;
	// if (y > 1 && a[x + 1][y - 1] == '#') return false;
	// if (y < n && a[x][y + 1] == '#') return false;
	// if (y < n && a[x + 1][y + 1] == '#') return false;
	return true;
}
bool check2(int x, int y) {
	if (y == n) return false;
	F(i, max(1, x - 1), min(n, x + 1))
		F(j, max(1, y - 1), min(n, y + 2))
			if (a[i][j] == '#') return false;
	return true;
}
bool work1(int i, int j) {//竖
	if (check1(i, j)) {
		a[i][j] = a[i + 1][j] = '#';
		return true;
	}
	return false;
}
bool work2(int i, int j) {//横
	if (check2(i, j)) {
		// debug << i << " " << j << endl;
		a[i][j] = a[i][j + 1] = '#';
		return true;
	}
	return false;
}
void zhk() {
	cin >> n;
	F(i, 1, n)
		F(j, 1, n)
			a[i][j] = '.';
	if (n % 6 == 5) {
		F(i, 1, n) {
			F(j, 1, n) {
				if (i % 3 && (j & 1)) cout << '#';
				else cout << '.';
			}
			cout << '\n';
		}
		return;
	}
	if (n == 8) {
		puts("#.#.##.#\n#.#....#\n....##..\n#......#\n#.##.#.#\n.....#..\n#.#....#\n#.#.##.#");
		return;
	}
	F(i, 1, n) {
		while (true) {
			bool flag = true;
			F(j, 1, n) {
				if (work1(j, i)) {
					flag = false;
					break;
				}
			}
			DF(j, n, 1) {
				if (work1(j, n - i + 1)) {
					flag = false;
					break;
				}
			}
			DF(j, n, 1) {
				// debug << i << " " << j << endl;
				if (work2(i, j)) {
					flag = false;
					break;
				}
			}
			F(j, 1, n) {
				if (work2(n - i + 1, j)) {
					flag = false;
					break;
				}
			}
			if (flag) break;
		}
		// if (i == 1) {
		// 	F(i, 1, n) {
		// 		F(j, 1, n)
		// 			cout << a[i][j];
		// 		cout << '\n';
		// 	}
		// 	debug << endl;
		// }
	}
	// F(i, 1, n) {
	// 	F(j, 1, n) {
	// 		if (check1(i, j)) {
	// 			a[i][j] = a[i + 1][j] = '#';
	// 		}
	// 	}
	// }
	// F(i, 1, n) {
	// 	F(j, 1, n) {
	// 		if (check2(i, j)) {
	// 			a[i][j] = a[i][j + 1] = '#';
	// 		}
	// 	}
	// }
	F(i, 1, n) {
		F(j, 1, n)
			cout << a[i][j];
		cout << '\n';
	}
}
signed main() {
	int _ = 1;
	cin >> _;
	while (_--) zhk();
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

input:

3
1
2
3

output:

.
#.
#.
#..
#.#
..#

result:

ok all tests correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3604kb

input:

50
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

output:

.
#.
#.
#..
#.#
..#
#.##
#...
...#
##.#
#.#.#
#.#.#
.....
#.#.#
#.#.#
#.#.##
#.#...
....##
##....
...#.#
##.#.#
#.##.##
#......
..#...#
#.#.#.#
#...#..
......#
##.##.#
#.#.##.#
#.#....#
....##..
#......#
#.##.#.#
.....#..
#.#....#
#.#.##.#
#.#.##.##
#.#......
....##.##
#.#......
#.#...#.#
......#.#
...

result:

wrong answer jury has the better answer: jans = 37, pans = 36 (test case 14)