QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#147442 | #6644. Red Black Grid | qzez# | WA | 10ms | 3748kb | C++14 | 1.7kb | 2023-08-23 09:33:28 | 2023-08-25 01:31:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
cerr<<x<<' ',debug(y...);
}
const int N=1e3+10;
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
int T,n,k;
vector<pair<int,int> >p[5];
bool chk(int x,int y){
return x>0&&y>0&&x<=n&&y<=n;
}
#define For(i) for(int l##i=p[i].size(),t##i=0;t##i<=l##i;t##i++)
#define Cover(i) for(int x##i=0;x##i<t##i;x##i++)cover(p[i][x##i]);
char ans[N][N];
bool solve(int x){
for(int i=0;i<5;i++)p[i].clear();
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
ans[i][j]='R';
if((i+j)%2==x)continue;
int cnt=0;
for(int k=0;k<4;k++){
cnt+=chk(i+dx[k],j+dy[k]);
}
p[cnt].push_back({i,j});
}
}
For(0)For(1)For(2)For(3){
if((k-t1-t2*2-t3*3)%4)continue;
int t4=(k-t1-t2*2-t3*3)/4;
if(t4<0||t4>(int)p[4].size())continue;
puts("Possible");
auto cover=[&](pair<int,int> x){
ans[x.first][x.second]='B';
};
Cover(0);
Cover(1);
Cover(2);
Cover(3);
Cover(4);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
putchar(ans[i][j]);
}
puts("");
}
return 1;
}
return 0;
}
void get(){
scanf("%d%d",&n,&k);
if(!solve(0)&&!solve(1))puts("Impossible");
}
int main(){
for(scanf("%d",&T);T--;)get();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3748kb
input:
2 3 6 3 1
output:
Possible RBR BRR RRR Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3552kb
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 R Possible RB BR Impossible Possible RB RR Impossible Possible RR RR Possible RBR BRB RBR Impossible Possible BRB RBR BRR Possible RBR BRB RRR Possible BRB RBR RRR Impossible Possible RBR BRR RRR Impossible Possible RRR RBR RRR Possible RBR RRR RRR Possible BRR RRR RRR Impossible Possible R...
result:
wrong answer Condition failed: "A == B" (test case 12)