QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#127685 | #6644. Red Black Grid | shielder | WA | 14ms | 3472kb | C++20 | 2.8kb | 2023-07-19 22:13:34 | 2023-07-19 22:13:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+10;
#define pll pair<int,int>
set<pll> c[3], s[3];
char a[N][N];
int tt, n, m;
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin >>tt;
while(tt--){
cin >> n >>m;
if(m == 1 || m == 2 * (n) * (n-1) - 1){
cout << "Impossible\n";
continue;
}
if(m == 2){
cout << "Possible\n";
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
a[i][j] = 'B';
}
a[i][n] = '\0';
}
a[0][0] = 'R';
for(int i = 0;i < n;i++){
cout <<a[i] <<"\n";
}
continue;
}
if(m == 3){
cout << "Possible\n";
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
a[i][j] = 'B';
}
a[i][n] = '\0';
}
a[0][1] = 'R';
for(int i = 0;i < n;i++){
cout <<a[i] <<"\n";
}
continue;
}
if(m == 4){
cout << "Possible\n";
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
a[i][j] = 'B';
}
a[i][n] = '\0';
}
a[0][0] = 'R';
a[n-1][n-1] ='R';
for(int i = 0;i < n;i++){
cout <<a[i] <<"\n";
}
continue;
}
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
a[i][j] = 'B';
}
a[i][n] = '\0';
}
if( m >= 4){
m-=4;
a[1][1] = 'R';
}
if(m == 3){
m-=3;
a[0][2] = 'R';
}
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
if(i == 0 && j == 0) j = 3;
if( ((i + j ) & 1 ) == 0 &&m && a[i][j] == 'B'){
int tmp = 4;
if(i == 0 || i == n-1) --tmp;
if(j ==0 ||j == n-1) --tmp;
if(m >= tmp){
m -= tmp;
a[i][j] ='R';
}
}
}
}
if(m == 1){
a[1][1] = 'B';
a[0][0] = 'R';
a[0][2] = 'R';
}
if(m == 2){
a[0][0] = 'R';
}
if(m == 3){
a[0][2] = 'R';
}
if(m == 5){
a[0][0] = 'R';
a[0][2] = 'R';
}
cout << "Possible\n";
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
cout << a[i][j];
}
cout << "\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3472kb
input:
2 3 6 3 1
output:
Possible BBB BRB RBB Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 14ms
memory: 3456kb
input:
4424 1 0 2 4 2 3 2 2 2 1 2 0 3 12 3 11 3 10 3 9 3 8 3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 4 24 4 23 4 22 4 21 4 20 4 19 4 18 4 17 4 16 4 15 4 14 4 13 4 12 4 11 4 10 4 9 4 8 4 7 4 6 4 5 4 4 4 3 4 2 4 1 4 0 5 40 5 39 5 38 5 37 5 36 5 35 5 34 5 33 5 32 5 31 5 30 5 29 5 28 5 27 5 26 5 25 5 24 5 23 5 22 5 21 5...
output:
Possible B Possible RB BR Impossible Possible RB BB Impossible Possible BB BB Possible BBB BRB RBR Impossible Possible RBB BRB RBR Possible RBR BBB RBR Possible BBB BRB RBR Possible BBR BRB BBB Possible BBB BRB RBB Possible RBR BBB BBB Possible RBB BBB BBR Possible BRB BBB BBB Possible RBB BBB BBB I...
result:
wrong answer Condition failed: "getNum(vec) == k" (test case 7)