結果

問題 No.331 CodeRunnerでやれ
ユーザー h_nosonh_noson
提出日時 2016-04-23 01:13:10
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,363 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 60,584 KB
最終ジャッジ日時 2024-04-27 02:20:08
合計ジャッジ時間 792 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:21: error: ‘tie’ was not declared in this scope
   43 |                     tie(a,b) = q.front();
      |                     ^~~
main.cpp:5:1: note: ‘std::tie’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
    4 | #include <queue>
  +++ |+#include <tuple>
    5 | using namespace std;

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int main() {
    int i, j, k, l, n, x, y, dir;
    int dxy[4] = {1,0,-1,0};
    int s[39][39] {};
    int d[39][39];
    x = y = 19;
    dir = 0;
    s[x][y] = 1;
    cin >> n;
    for (;;) {
        for (i = 0; i < 4 && n != 20151224; i++) {
            s[x+(n+1)*dxy[dir]][y+(n+1)*dxy[(dir+1)%4]] = 2;
            while (n--) s[x+(n+1)*dxy[dir]][y+(n+1)*dxy[(dir+1)%4]] = 1;
            cout << "L" << endl;
            cin >> n;
            dir = (dir + 1) % 4;
        }
        if (n == 20151224)
            break;
        bool found = false;
        REP (i,1,37) REP (j,1,37) if (!found && !s[i][j]) {
            rep (k,4) if (s[i+dxy[k]][j+dxy[(k+1)%4]] == 1) {
                queue<pair<int,int>> q;
                q.push(make_pair(i+dxy[k],j+dxy[(k+1)%4]));
                rep (l,39) fill(d[l],d[l]+39,INF);
                d[i+dxy[k]][j+dxy[(k+1)%4]] = 0;
                while (!q.empty()) {
                    int a, b;
                    tie(a,b) = q.front();
                    q.pop();
                    if (a == x && b == y)
                        break;
                    rep (l,4) {
                        int na, nb;
                        na = a+dxy[l];
                        nb = b+dxy[(l+1)%4];
                        if (s[na][nb] == 1 && d[a][b] + 1 < d[na][nb]) {
                            d[na][nb] = d[a][b] + 1;
                            q.push(make_pair(na,nb));
                        }
                    }
                }
                while (d[x][y] > 0) {
                    while (d[x][y] != d[x+dxy[dir]][y+dxy[(dir+1)%4]] + 1) {
                        cout << "L" << endl;
                        cin >> n;
                        dir = (dir + 1) % 4;
                    }
                    cout << "F" << endl;
                    cin >> n;
                    x += dxy[dir]; y+= dxy[(dir+1)%4];
                }
                found = true;
            }
        }
    }
    cin.ignore();
    string str;
    while (cout << "F" << endl, getline(cin,str), str != "Merry Christmas!");
    return 0;
}
0