Submission #1108593
Source Code Expand
int[Point] up; int[Point] down; int[Point] right; int[Point] left; Point move(Point p, char dir) { auto np = p; if (dir == 'U') np.y = up[p]; else if (dir == 'D') np.y = down[p]; else if (dir == 'R') np.x = right[p]; else if (dir == 'L') np.x = left[p]; else assert(true); Point u = Point(np.x, np.y+1); Point d = Point(np.x, np.y-1); Point r = Point(np.x+1, np.y); Point l = Point(np.x-1, np.y); int nu = (u in up) ? up[u] : np.y + 1; int nd = (d in down) ? down[d] : np.y - 1; int nr = (r in right) ? right[r] : np.x + 1; int nl = (l in left) ? left[l] : np.x - 1; up[Point(np.x, nd+1)] = nu; down[Point(np.x, nu-1)] = nd; right[Point(nl+1, np.y)] = nr; left[Point(nr-1, np.y)] = nl; up[np] = nu; down[np] = nd; right[np] = nr; left[np] = nl; return np; } void main() { auto K = readln.chomp.to!int; auto S = readln.chomp; Point p = Point(0, 0); up[p] = 1; down[p] = -1; right[p] = 1; left[p] = -1; foreach (i; 0..K) { p = move(p, S[i]); } writeln(p[0], " ", p[1]); }
Submission Info
Submission Time | |
---|---|
Task | C - 幼稚園児高橋君 |
User | nebukuro09 |
Language | D (DMD 2.066.1) |
Score | 0 |
Code Size | 1191 Byte |
Status | CE |
Compile Error
./Main.d(1): Error: undefined identifier Point ./Main.d(2): Error: undefined identifier Point ./Main.d(3): Error: undefined identifier Point ./Main.d(4): Error: undefined identifier Point ./Main.d(6): Error: undefined identifier Point ./Main.d(6): Error: undefined identifier Point