Submission #65019755


Source Code Expand

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <array>
#include <vector>

using namespace std;
int N, K;
int maxScore = 0;
int grid[21][21];
int x = 0;
int y = 0;
void dfs(int curNum, int curVal)
{
    if (curNum == 2 * (N - 1))
    {
        maxScore = max(maxScore, (curVal * 10 + grid[x][y]) % K);
        return;
    }
    else
    {
        curVal = (curVal * 10 + grid[x][y]) % K;
        if (x != N - 1)
        {
            x++;
            dfs(curNum + 1, curVal);
            x--;
        }
        if (y != N - 1)
        {
            y++;
            dfs(curNum + 1, curVal);
            y--;
        }
        return;
    }
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> grid[i][j];
        }
    }
    dfs(0, 0);
    cout << maxScore << endl;
}

Submission Info

Submission Time
Task F - Path to Integer
User helperT
Language C++ 23 (gcc 12.2)
Score 0
Code Size 1010 Byte
Status WA
Exec Time 2210 ms
Memory 3612 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 525
Status
AC × 3
AC × 14
WA × 6
TLE × 24
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3528 KiB
00_sample_01.txt AC 1 ms 3528 KiB
00_sample_02.txt AC 1 ms 3512 KiB
01_handmade_00.txt AC 1 ms 3536 KiB
01_handmade_01.txt AC 1 ms 3480 KiB
01_handmade_02.txt AC 1 ms 3456 KiB
01_handmade_03.txt AC 1 ms 3412 KiB
01_handmade_04.txt AC 2 ms 3412 KiB
01_handmade_05.txt WA 622 ms 3456 KiB
01_handmade_06.txt TLE 2207 ms 3212 KiB
01_handmade_07.txt TLE 2207 ms 3320 KiB
01_handmade_08.txt TLE 2207 ms 3220 KiB
01_handmade_09.txt TLE 2207 ms 3276 KiB
01_handmade_10.txt AC 1 ms 3536 KiB
01_handmade_11.txt AC 43 ms 3604 KiB
01_handmade_12.txt TLE 2210 ms 3376 KiB
01_handmade_13.txt TLE 2207 ms 3200 KiB
01_handmade_14.txt TLE 2207 ms 3296 KiB
01_handmade_15.txt TLE 2207 ms 3292 KiB
02_random_00.txt AC 1 ms 3612 KiB
02_random_01.txt WA 12 ms 3472 KiB
02_random_02.txt WA 2 ms 3452 KiB
02_random_03.txt AC 43 ms 3536 KiB
02_random_04.txt AC 1 ms 3472 KiB
02_random_05.txt WA 4 ms 3476 KiB
02_random_06.txt WA 1 ms 3472 KiB
02_random_07.txt AC 12 ms 3408 KiB
02_random_08.txt TLE 2210 ms 3216 KiB
02_random_09.txt WA 4 ms 3488 KiB
02_random_10.txt TLE 2207 ms 3216 KiB
02_random_11.txt TLE 2207 ms 3204 KiB
02_random_12.txt TLE 2207 ms 3368 KiB
02_random_13.txt TLE 2210 ms 3308 KiB
02_random_14.txt TLE 2207 ms 3344 KiB
02_random_15.txt TLE 2207 ms 3260 KiB
02_random_16.txt TLE 2207 ms 3272 KiB
02_random_17.txt TLE 2207 ms 3288 KiB
02_random_18.txt TLE 2207 ms 3200 KiB
02_random_19.txt TLE 2207 ms 3292 KiB
02_random_20.txt TLE 2207 ms 3264 KiB
02_random_21.txt TLE 2207 ms 3304 KiB
02_random_22.txt TLE 2207 ms 3292 KiB
02_random_23.txt TLE 2207 ms 3276 KiB
02_random_24.txt TLE 2207 ms 3316 KiB