QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#644701 | #7398. Triangle Tiling | cjx | WA | 3ms | 5744kb | C++20 | 1.1kb | 2024-10-16 15:10:09 | 2024-10-16 15:10:18 |
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(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();
while(T--){
n=read();
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cin>>a[i][j];
}
}
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5688kb
input:
1 4 0 11 010 1101
output:
- 32 -1- 33-1
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 5744kb
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- - 32 -12 3--2 3-112 3--112 3333322 - -- --1 3332 333-2 333322 2 -2 322 3222 3-222 3-122- 33-12-1 333323-- 2 -- - -1 - -1 33- 2 -- -11 3-1- 33-11 33-111 3333332 2 22 222 2-22 23-2- -3323- 33-133- -1111111 2 -- -1- 3332 3-112 - 3- -11 -1-1 -1111 333332 2 -- 3-- 3332 2 -2 32-...
result:
wrong answer jury does not has a solution while user does