QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398480#2540. Build The Gridhaze#WA 1ms3712kbC++231.8kb2024-04-25 13:35:042024-04-25 13:35:05

Judging History

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

  • [2024-04-25 13:35:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2024-04-25 13:35:04]
  • 提交

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;
}

详细

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