結果

問題 No.5022 XOR Printer
ユーザー Hyoka7
提出日時 2025-07-26 14:13:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 220,276 KB
実行使用メモリ 7,716 KB
スコア 2,659,818,750
最終ジャッジ日時 2025-07-26 14:13:08
合計ジャッジ時間 4,593 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < (int)(n); i++)
using ll = long long;

vector<int> movevec = {0, 1, 0, -1, 0};
vector<char> movedir = {'R', 'D', 'L', 'U'};

int main()
{
    int n, t;
    cin >> n >> t;
    vector<vector<int>> grid(n, vector<int>(n));
    rep(i, 0, n) rep(j, 0, n) cin >> grid[i][j];
    int nowx = 0, nowy = 0;
    int score = 0;
    string ans = "";
    rep(_, 0, t)
    {
        int maxres = 0;
        int dir = 0;
        rep(d, 0, 4)
        {
            int nx = nowx + movevec[d], ny = nowy + movevec[d + 1];
            if ((0 <= nx && nx < n) && (0 <= ny && ny < n))
            {
                if (maxres < score ^ grid[nx][ny])
                {
                    maxres = score ^ grid[nx][ny];
                    dir = d;
                }
            }
        }
        ans += movedir[dir];
        nowx += movevec[dir];
        nowy += movevec[dir];
    }
    for (char c : ans)
    {
        cout << c << endl;
    }
}
0