Submission #73132440


Source Code Expand

#include <iostream>
using namespace std;
int n;
string s[105];
int tag[205];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> s[i], s[i] = " " + s[i];
    for (int i = 1; i <= (n << 1); i++)
        tag[i] = -1;
    bool flag = true;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (s[i][j] != '?')
            {
                if (tag[i + j] == -1)
                    tag[i + j] = s[i][j] - '0';
                else if (tag[i + j] != s[i][j] - '0')
                {
                    flag = false;
                    break;
                }
            }
    if (flag)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
                cout << (tag[i + j] == -1 ? 0 : tag[i + j]);
            cout << "\n";
        }
    }
    else
        cout << "-1";
}

Submission Info

Submission Time
Task A - Same Sum Grid Path
User Hygrox
Language C++23 (GCC 15.2.0)
Score 300
Code Size 970 Byte
Status AC
Exec Time 2 ms
Memory 3712 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 3500 KiB
01-02.txt AC 1 ms 3628 KiB
01-03.txt AC 1 ms 3496 KiB
01-04.txt AC 2 ms 3628 KiB
01-05.txt AC 2 ms 3712 KiB
01-06.txt AC 2 ms 3636 KiB
01-07.txt AC 1 ms 3688 KiB
01-08.txt AC 1 ms 3660 KiB
01-09.txt AC 1 ms 3684 KiB
01-10.txt AC 1 ms 3516 KiB
01-11.txt AC 1 ms 3660 KiB
01-12.txt AC 1 ms 3684 KiB
01-13.txt AC 1 ms 3532 KiB
sample-01.txt AC 1 ms 3532 KiB
sample-02.txt AC 1 ms 3380 KiB
sample-03.txt AC 1 ms 3500 KiB