QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#466234 | #6644. Red Black Grid | ucup-team191# | WA | 0ms | 3824kb | C++23 | 1.5kb | 2024-07-07 17:06:22 | 2024-07-07 17:06:22 |
Judging History
answer
#include <cstdio>
#include <vector>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef pair < int, int > pii;
const int N = 1e3 + 50;
vector < pii > v;
int A[N][N], n, k;
char zn[2] = {'R', 'B'};
void solve() {
int flip = 0;
scanf("%d%d", &n, &k);
if(k > n * (n - 1)) {
flip = 1;
k = 2 * n * (n - 1) - k;
}
for(int i = 0;i < n;i++)
for(int j = 0;j < n;j++)
A[i][j] = 0;
if(k == 1) {
printf("NO\n");
return;
}
if(n == 1) {
A[0][0] = 0;
} else if(n == 2) {
if(k == 2){
A[1][0] = 1;
A[1][1] = 1;
}
} else if(n == 3) {
if(k == 2) {
A[0][0] = 1;
} else if(k == 3) {
A[0][1] = 1;
} else if(k == 4) {
A[0][0] = 1;
A[2][2] = 1;
} else if(k == 5) {
A[0][0] = 1;
A[2][1] = 1;
} else if(k == 6) {
A[0][1] = 1;
A[1][0] = 1;
}
} else {
if(k % 4 == 0 && k > 0) {
A[0][0] = 1; A[n - 1][n - 1] = 1;
k -= 4;
}
if(k % 4 == 1) {
A[0][0] = 1; A[0][2] = 1;
k -= 4;
} else if(k % 4 == 2) {
A[0][0] = 1;
} else if(k % 4 == 3) {
A[0][2] = 1;
}
k -= k % 4;
for(int i = 1;i + 1 < n;i++) {
for(int j = 1;j + 1 < n;j++)
if((i + j) % 2 == 0 && k > 0) {
A[i][j] = 1; k -= 4;
}
}
if(k > 0) {
printf("koji kurac\n");
}
}
printf("YES\n");
for(int i = 0;i < n;i++) {
for(int j = 0;j < n;j++)
printf("%c", zn[(flip ? (i + j) % 2 : 0) ^ A[i][j]]);
printf("\n");
}
}
int main() {
int T; scanf("%d", &T);
for(;T--;) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
2 3 6 3 1
output:
YES RBR BRR RRR NO
result:
wrong answer Condition failed: "A == B" (test case 1)