Submission #73131379


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=105,inf=2e9;
int read() {
	static int f=1,c=getchar(),x=0;
	for(f=1; c<=47||c>=58; c=getchar())f=f&&(c!=45);
	for(x=0; c>=48&&c<=57; c=getchar())x=(x<<3)+(x<<1)+(c&15);
	return f?x:-x;
}
void print(int x) {
	if(x>9)print(x/10);
	putchar((x%10)|48);
}
int n,a[MAXN][MAXN];
char c[1];
void solve() {
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%1s",c),a[i][j]=c[0]=='?'?-1:c[0]-'0';
	for(int s=2; s<=n+n; ++s) {
		int id=-1;
		for(int j=max(s-n,1); j<=n&&j<s; ++j) {
			int i=s-j;
			if(~a[i][j]&&a[i][j]!=id) {
				if(~id) {
					printf("-1\n");
					return;
				} else id=a[i][j];
			}
		}
		id=max(id,0);
		for(int j=max(s-n,1); j<=n&&j<s; ++j)a[s-j][j]=id;
	}
	for(int i=1; i<=n; ++i,putchar(10))
		for(int j=1; j<=n; ++j)
			putchar(a[i][j]|48);
}
int main() {
	int t=1;
	while(t--)solve();
	return 0;
}

Submission Info

Submission Time
Task A - Same Sum Grid Path
User mod998244353
Language C++23 (GCC 15.2.0)
Score 300
Code Size 965 Byte
Status AC
Exec Time 1 ms
Memory 3988 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 16
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 3728 KiB
01-02.txt AC 1 ms 3824 KiB
01-03.txt AC 1 ms 3656 KiB
01-04.txt AC 1 ms 3732 KiB
01-05.txt AC 1 ms 3840 KiB
01-06.txt AC 1 ms 3896 KiB
01-07.txt AC 1 ms 3764 KiB
01-08.txt AC 1 ms 3872 KiB
01-09.txt AC 1 ms 3932 KiB
01-10.txt AC 1 ms 3796 KiB
01-11.txt AC 1 ms 3792 KiB
01-12.txt AC 1 ms 3856 KiB
01-13.txt AC 1 ms 3988 KiB
sample-01.txt AC 1 ms 3732 KiB
sample-02.txt AC 1 ms 3768 KiB
sample-03.txt AC 1 ms 3712 KiB