QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644768#7398. Triangle TilingcjxWA 3ms5792kbC++201.3kb2024-10-16 15:26:082024-10-16 15:26:14

Judging History

你现在查看的是最新测评结果

  • [2024-10-16 15:26:14]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5792kb
  • [2024-10-16 15:26:08]
  • 提交

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();
	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;
}
/*
1
7
0
11
011
1001
10111
100111
1111111
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5728kb

input:

1
4
0
11
010
1101

output:

-
32
-1-
33-1

result:

ok ok

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 5792kb

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!
2
--
-
-1
-
-1
33-
Impossible!
2
22
222
2-22
23-2-
-3323-
33-133-
-1111111
Impossible!
Impossible!
Impossible!
Impossible!
2
--
2
--
Impossible!
Impossible!
-
-1
Impossible!
2
22
2--
-3-1
Impossible!
Impossible!
Impossible!
Impossible!
2...

result:

wrong answer jury has a solution while user does not