QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644807#7398. Triangle TilingcjxWA 1ms5616kbC++201.4kb2024-10-16 15:31:122024-10-16 15:31:13

Judging History

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

  • [2024-10-16 15:31:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5616kb
  • [2024-10-16 15:31:12]
  • 提交

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

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5616kb

input:

1
4
0
11
010
1101

output:


result:

wrong output format Unexpected end of file - token expected