QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#134912 | #6644. Red Black Grid | little_brush# | WA | 7ms | 3684kb | C++14 | 1.6kb | 2023-08-05 09:57:35 | 2023-08-05 09:57:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0,f=1;
char c=getchar();
while(c<'0' || c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while(c>='0' && c<='9')
{
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
const int N=1000+5;
int n,m;
bool vis[N][N];
inline int ask(int x,int y)
{
if(x==1 && y==1) return 2;
if(x==1 && y==n) return 2;
if(x==n && y==1) return 2;
if(x==n && y==n) return 2;
if(x==1 || x==n || y==1 || y==n) return 3;
return 4;
}
int main()
{
int T=read();
while(T--)
{
n=read(); m=read();
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
vis[i][j]=false;
int c1=0,c2=0,c3=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if((i+j)%2==1) continue;
int k=ask(i,j);
if(k==2) c1++;
else if(k==3) c2++;
else if(k==4) c3++;
}
int cnt1=0,cnt2=0,cnt3=0;
//cout<<cnt1<<" "<<cnt2<<" "<<cnt3<<endl;
if(m<3) cnt2=0;
else if(m%2==1) cnt2=min(c2,(m-3)/6*2+1), m-=cnt2*3;
else cnt2=min(c2,m/6*2), m-=cnt2*3;
cnt3=min(c3,m/4), m-=cnt3*4;
cnt1=min(c1,m/2), m-=cnt1*2;
if(m)
{
printf("Impossible\n");
continue;
}
else
{
printf("Possible\n");
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if((i+j)%2==1) continue;
int k=ask(i,j);
if(k==2 && cnt1) vis[i][j]=true, cnt1--;
if(k==3 && cnt2) vis[i][j]=true, cnt2--;
if(k==4 && cnt3) vis[i][j]=true, cnt3--;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
if(vis[i][j])
putchar('R');
else
putchar('B');
putchar('\n');
}
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
2 3 6 3 1
output:
Possible RBB BRB BBB Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3548kb
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 RBR BRB RBR Impossible Possible RBR BRB RBB Impossible Possible RBR BRB BBB Impossible Possible RBB BRB BBB Impossible Possible BBB BRB BBB Impossible Possible RBB BBB BBB Impossible Possible BBB BBB BBB Possible ...
result:
wrong answer Condition failed: "A == B" (test case 10)