QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#644742 | #7398. Triangle Tiling | cjx | WA | 1ms | 5808kb | C++20 | 1.4kb | 2024-10-16 15:21:08 | 2024-10-16 15:21:08 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long read(){
long long x=0,f=1;char ch=getchar();
while(!isdigit(ch))
{if(ch=='-') f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
void write(long long x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
const int N=5010;
int T,n;
char a[N][N],b[N][N];
void solve(){
int cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
if(a[i][j]=='0'){
b[i][j]='-';cnt++;continue;
}
if(j>1&&b[i][j-1]!='3'&&b[i-1][j-1]!='2'){
b[i][j]='1';continue;
}
if(j<i&&b[i-1][j]!='2'){
b[i][j]='3';continue;
}
b[i][j]='2';
if(i==n){
//printf("Impossible\n");return;
}
}
}
for(int i=2;i<=n;i++){
for(int j=1;j<i;j++){
if(b[i][j]!='3'&&b[i][j+1]!='1'&&b[i-1][j]!='2'){
printf("Impossible\n");return;
}
}
}
if(cnt!=n){
printf("Impossible\n");return;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
putchar(b[i][j]);
}
puts("");
}
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
T=read();
int tot=0;
while(T--){
n=read();tot++;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cin>>a[i][j];
}
}
solve();
if(tot==4)return 0;
}
return 0;
}
/*
1
6
0
00
001
1111
11101
111111
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5720kb
input:
1 4 0 11 010 1101
output:
- 32 -1- 33-1
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5808kb
input:
909 6 0 11 100 1111 11100 111110 7 0 11 011 1001 10111 100111 1111111 6 0 00 001 1111 11101 111111 8 1 01 111 1111 10111 101110 1101101 11111100 2 1 00 2 0 01 3 0 01 110 7 1 00 011 1010 11011 110111 1111111 8 1 11 111 1011 11010 011110 1101110 01111111 5 1 00 010 1111 10111 6 0 10 011 0101 01111 111...
output:
- 32 3-- 3332 333-- 33333- Impossible Impossible Impossible
result:
wrong answer jury does not has a solution while user does