답안 #660618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660618 2022-11-22T16:22:31 Z USER 로봇 (APIO13_robots) C++14
0 / 100
1500 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pr;
int k, n, m, a[501][501][9];
char c[501][501];

const int inf = 1000000000;
pr go[4][501][501];

void afis(pr aux)
{
    cout << aux.first << ' ' << aux.second << '\n';
}

// 0 - Up, 1 - Left, 2 - Down, 3 - Right

int d1[] = { -1, 0, 1, 0 };
int d2[] = { 0, 1, 0, -1 };

inline bool in(int i, int j)
{
    return i >= 1 && i <= n && j >= 1 && j <= m;
}

inline void prev(int& dir)
{
    dir--;
    if (dir == -1)
        dir = 3;
}

inline void next(int& dir)
{
    dir++;
    if (dir == 4)
        dir = 0;
}

pr get(int dir, int i, int j)
{
    if (!in(i, j))
    {
        if (!i)
            i++;
        else if (!j)
            j++;
        else if (i == n + 1)
            i--;
        else if (j == m + 1)
            j--;

        return { i, j };
    }

    if (c[i][j] == 'x')
    {
        next(dir);
        next(dir);
        return { i + d1[dir], j + d2[dir] };
    }

    if (go[dir][i][j].first)
        return go[dir][i][j];

    int nxDir = dir;

    if (c[i][j] == 'A')
        prev(nxDir);
    else if (c[i][j] == 'C')
        next(nxDir);

    pr aux = get(nxDir, i + d1[nxDir], j + d2[nxDir]);
    go[dir][i][j] = aux;
    return aux;
}

int main()
{
  while (true);
  
    cin >> k >> m >> n;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            cin >> c[i][j];
            if (isdigit(c[i][j]))
                c[i][j]--;
        }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            for (int l = 0; l <= 3; l++)
                get(l, i, j);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)


    return 0;
}

Compilation message

robots.cpp: In function 'int main()':
robots.cpp:80:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   80 |   while (true);
      |   ^~~~~
robots.cpp:82:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   82 |     cin >> k >> m >> n;
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -