67762023-12-19 09:39:07TimiSzörnyekcpp17Wrong answer 0/10059ms6132 KiB
#include <iostream>

using namespace std;
const int N=20, M=20;

bool Matrixban(int x, int y, int n, int m)
{
    return 0<=x && x<n && 0<=y && y<m;
}

bool keres(int x, int y, int celx, int cely, char lab[N][M])
{
    if (x==celx && y==cely)
        return true;
    lab[x][y]='*';
    if (Matrixban(x-1, y, celx+1, cely+1) && lab[x-1][y]=='.')
        if (keres(x-1, y, celx, cely, lab))
           return true;
    if (Matrixban(x, y+1, celx+1, cely+1) && lab[x][y+1]=='.')
        if (keres(x, y+1, celx, cely, lab))
           return true;
    if (Matrixban(x+1, y, celx+1, cely+1) && lab[x+1][y]=='.')
        if (keres(x+1, y, celx, cely, lab))
           return true;
    if (Matrixban(x, y-1, celx+1, cely+1) && lab[x][y-1]=='.')
        if (keres(x, y-1, celx, cely, lab))
           return true;

    return false;

}
int main()
{
    int n, m;
    cin>>n>>m;
    char lab[N][M];
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
           cin>>lab[i][j];
    if (keres(0, 0, n-1, m-1, lab))
        cout<<"igen";
    else
        cout<<"nem";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1872 KiB
2Wrong answer3ms2068 KiB
subtask20/13
3Wrong answer3ms2312 KiB
4Wrong answer3ms2560 KiB
5Wrong answer3ms2696 KiB
6Wrong answer3ms2872 KiB
subtask30/22
7Wrong answer3ms3092 KiB
8Wrong answer4ms3304 KiB
9Wrong answer3ms3520 KiB
10Wrong answer3ms3580 KiB
11Wrong answer3ms3588 KiB
12Wrong answer3ms3704 KiB
13Wrong answer4ms3808 KiB
14Wrong answer4ms3896 KiB
subtask40/65
15Runtime error59ms5140 KiB
16Runtime error3ms5072 KiB
17Runtime error3ms5268 KiB
18Runtime error3ms5292 KiB
19Runtime error3ms5296 KiB
20Runtime error8ms5828 KiB
21Runtime error3ms5932 KiB
22Runtime error3ms5724 KiB
23Runtime error3ms6132 KiB
24Runtime error3ms5992 KiB