QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#398480 | #2540. Build The Grid | haze# | WA | 1ms | 3712kb | C++23 | 1.8kb | 2024-04-25 13:35:04 | 2024-04-25 13:35:05 |
Judging History
answer
/*
Author: Haze
2024/4/25
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;
inline ll read() {
ll s = 0;
bool fl = false;
char ch = (char) getchar();
while (!isdigit(ch)) {
if (ch == '-')fl = true;
ch = (char) getchar();
}
while (isdigit(ch)) {
s = s * 10 + (ch ^ 48);
ch = (char) getchar();
}
return fl ? -s : s;
}
const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;
char g[555][555];
void dfs(int x1, int y1, int x2, int y2){
if(x1 + 1 == x2 && y1 + 1 == y2){
irep(i, x1, x2){
irep(j, y1, y2){
g[i][j] = 'W';
}
}
g[x1][y1] = 'B';
return;
}
if(x1 + 2 == x2 && y1 + 2 == y2){
vector<array<char, 3>>p = {
{'W','W','B'},
{'B','W','B'},
{'W','W','W'}
};
irep(i, 0, 2){
irep(j,0,2){
g[x1 + i][y1 + j] = p[i][j];
}
}
return;
}
irep(i, x1, x2){
g[i][y2] = 'B';
}
irep(j, y1, y2){
g[x2][j] = 'B';
}
irep(i, x1, x2){
g[i][y1] = 'W';
}
irep(j, y1, y2){
g[x1][j] = 'W';
}
dfs(x1 + 1, y1 + 1, x2 - 1, y2 - 1);
// return;
}
void solve() {
int n = read();
dfs(1,1,n,n);
irep(i, 1, n){
irep(j, 1, n){
cout << g[i][j];
}
cout << '\n';
}
return;
}
int main() {
// IOS
int T = 1;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
input:
3
output:
WWB BWB WWW
result:
ok accepted
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2
output:
BW WW
result:
ok accepted
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
4
output:
WWWW WBWB WWWB WBBB
result:
wrong answer there are no white cells around a black cell