Submission #73131627


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vvvl=vector<vector<vector<long long>>>;
using pl=pair<long long,long long>;
using vpl=vector<pair<long long,long long>>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(long long i=(long long)(a);i<(long long)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#include <atcoder/all>
using namespace atcoder;

long long modpow(long long a, long long n, long long mo){long long res=1;while(n>0){if(n&1){res=res*a%mo;}a=a*a%mo;n>>=1;}return res;}
long long Pow(long long a, long long n){long long res=1;while(n>0){if(n&1){res=res*a;}a=a*a;n>>=1;}return res;}

const ll MOD=998244353;
const ll INF=(1ll<<60);
int main(){
  ll N;
  cin>>N;
  vector<vector<char>> S(N,vector<char>(N));
  rep(i,N)rep(j,N) cin>>S[i][j];
  bool ok=true;
  rep(k,2*N-1){
    ll atai=-1;
    rep(i,N){
      if(k-i<0) continue;
      if(k-i>=N) continue;
      ll j=k-i;
      if(S[i][j]!='?'){
        ll mem=S[i][j]-'0';
        if(atai==-1) atai=mem;
        if(atai!=mem){
          ok=false;
        }
      }
    }
    if(atai==-1) atai=0;
    rep(i,N){
      if(k-i<0) continue;
      if(k-i>=N) continue;
      ll j=k-i;
      S[i][j]=atai+'0';
    }
  }
  if(ok){
    rep(i,N){
      rep(j,N) cout<<S[i][j];
      cout<<endl;
    }
  }
  else cout<<-1<<endl;
}

Submission Info

Submission Time
Task A - Same Sum Grid Path
User number_cat
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1651 Byte
Status AC
Exec Time 1 ms
Memory 3588 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 3564 KiB
01-02.txt AC 1 ms 3404 KiB
01-03.txt AC 1 ms 3468 KiB
01-04.txt AC 1 ms 3512 KiB
01-05.txt AC 1 ms 3460 KiB
01-06.txt AC 1 ms 3576 KiB
01-07.txt AC 1 ms 3468 KiB
01-08.txt AC 1 ms 3512 KiB
01-09.txt AC 1 ms 3372 KiB
01-10.txt AC 1 ms 3460 KiB
01-11.txt AC 1 ms 3512 KiB
01-12.txt AC 1 ms 3588 KiB
01-13.txt AC 1 ms 3468 KiB
sample-01.txt AC 1 ms 3400 KiB
sample-02.txt AC 1 ms 3516 KiB
sample-03.txt AC 1 ms 3516 KiB