QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398494#2540. Build The Gridhaze#WA 1ms3644kbC++231.5kb2024-04-25 13:59:212024-04-25 13:59:23

Judging History

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

  • [2024-04-25 13:59:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-04-25 13:59:21]
  • 提交

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

int line[N], col[N];
void solve() {
    int n = read();
    irep(i, 1, n){
        line[i] = col[i] = 1;
        if(i > 1)
        if(i % 2 == 1)line[i] = i - 1;
        else col[i] = i - 1;
    }
    irep(i, 1, n){
        irep(j, 1, n){
            g[i][j] = 'B';
        }
    }
    irep(i, 1, n){
        irep(j, 1, line[i])g[i][j] = 'W';
    }
    irep(j, 1, n){
        irep(i, 1, col[j])
        g[i][j] = 'W';
    }
    if(n & 1){
        swap(g[n], g[n - 1]);
        swap(g[n - 1], g[1]);
    }
    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: 3644kb

input:

3

output:

WWB
WWW
WBB

result:

ok accepted

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2

output:

WW
WB

result:

ok accepted

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3644kb

input:

4

output:

WWWW
WBBW
WWBW
WBBB

result:

wrong answer there are no white cells around a black cell