結果
問題 | No.331 CodeRunnerでやれ |
ユーザー | bal4u |
提出日時 | 2019-08-15 22:50:38 |
言語 | C (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,741 bytes |
コンパイル時間 | 418 ms |
コンパイル使用メモリ | 28,544 KB |
実行使用メモリ | 76,524 KB |
平均クエリ数 | 85.59 |
最終ジャッジ日時 | 2024-07-16 17:55:51 |
合計ジャッジ時間 | 9,960 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 139 ms
25,232 KB |
testcase_01 | AC | 132 ms
25,232 KB |
testcase_02 | AC | 163 ms
25,232 KB |
testcase_03 | AC | 162 ms
24,976 KB |
testcase_04 | AC | 170 ms
24,964 KB |
testcase_05 | AC | 164 ms
24,964 KB |
testcase_06 | AC | 160 ms
25,232 KB |
testcase_07 | AC | 195 ms
24,964 KB |
testcase_08 | AC | 184 ms
24,976 KB |
testcase_09 | AC | 236 ms
25,348 KB |
testcase_10 | AC | 198 ms
24,836 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
ソースコード
// yukicoder: No.331 CodeRunnerでやれ // bal4u 2019.8.15 #include <stdio.h> #include <stdlib.h> #if 0 int H = 19, W = 17; char map[25][25] = { "#################", "#>..............#", "###############.#", "#.............#.#", "#.###########.#.#", "#.#.........#.#.#", "#.#.#######.#.#.#", "#.#.#.....#.#.#.#", "#.#.#.###.#.#.#.#", "#.#.#.#...#.#.#.#", "#.#.#.#.###.#.#.#", "#.#.#.#.....#.#.#", "#.#.#.#######.#.#", "#.#.#.........#.#", "#.#.###########.#", "#.#.............#", "#.###############", "#...............#", "###############.#", }; int H = 19, W = 19; char map[25][25] = { "###################", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#^#.#.#", "#####.#############" }; int H = 20, W = 20; char map[25][25] = { "####################", "#..........#.#...#.#", "##..#..##.#....#...#", "#.##.#...#.#.#..##.#", "#......#.#..#.#..#..", "#.#.#.#.#..#...#..##", "#..#.....#...#..#.##", "#.#..#.#..#.#.#....#", "#..##...#.....#.##.#", "#.#.###..####.#..#.#", "#.#....#.......#..##", "#..#.#..#.#.###..#.#", "#.#..#.#..##...##..#", "#..#..#..#...#...#.#", "#.#..#.#...#..##...#", "#.##.....#..##...#.#", "#...#.#.#.#...#.#..#", "##.#>#.#.#..##...#.#", "#....#.....#...##..#", "####################" }; int H = 19, W = 19; char map[25][25] = { "###################", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "..#.#.#.#.#.#.#<#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.................#", "###################" }; int H = 19, W = 17; char map[25][25] = { "#################", "#>..............#", "###############.#", "#.............#.#", "#.###########.#.#", "#.#.........#.#.#", "#.#.#######.#.#.#", "#.#.#.....#.#.#.#", "#.#.#.###.#.#.#.#", "#.#.#.#...#.#.#.#", "#.#.#.#.###.#.#.#", "#.#.#.#.....#.#.#", "#.#.#.#######.#.#", "#.#.#.........#.#", "#.#.###########.#", "#.#.............#", "#.###############", "#...............#", "###############.#" }; #endif #define TEST 0 int H = 19, W = 19; char map[25][25] = { "###################", "#.................#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#.#.#.#", "#.#.#.#.#.#.#^#.#.#", "#####.#############" }; int r, c, dir, step; int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}}; void init() { #if TEST for (r = 0; r < H; r++) for (c = 0; c < W; c++) { if (map[r][c] == '^') { dir = 0; return; } if (map[r][c] == 'v') { dir = 2; return; } if (map[r][c] == '<') { dir = 3; return; } if (map[r][c] == '>') { dir = 1; return; } } printf("Panic!!! no initial (r,c)\n"); exit(0); #endif } void move(char *s, char ch) { #if TEST int rr, cc; *(s+1) = 0; if (ch == 'L') { if (--dir < 0) dir += 4; rr = r + mv[dir][0], cc = c + mv[dir][1]; *s = (map[rr][cc] != '#')? '1': '0'; } else if (ch == 'R') { if (++dir == 4) dir -= 4; rr = r + mv[dir][0], cc = c + mv[dir][1]; *s = (map[rr][cc] != '#')? '1': '0'; } else if (ch == 'F') { rr = r + mv[dir][0], cc = c + mv[dir][1]; if (rr < 0 || rr >= H || cc < 0 || cc >= W) *s = 'M'; else { if (map[rr][cc] != '#') r = rr, c = cc, *s = '1'; else *s = '0'; } } else if (ch == 'B'); else *s = (map[r][c] != '#')? '1': '0'; printf("ch=%c, (%d,%d) dir=%d\n", ch, r,c,dir); if (++step > 5000) { printf("Time over\n"); exit(0); } #endif } int action(char ch) { char s[20]; int d; while (1) { #if TEST move(s, ch); #else if (ch) { putchar(ch), putchar('\n'); fflush(stdout); } scanf("%s", s); #endif if (*s == 'M') { #if TEST printf("OK steps=%d\n", step); #endif exit(0); } if ((d = atoi(s)) < 20151224) break; ch = 'F'; } return d; } int main() { int d; char a; init(); d = action(0); while (d) d = action('F'); d = action('L'); while (d) d = action('F'); d = action('L'); while (1) { if (d == 0) d = action('R'); while (d == 0) d = action('L'); while (d = action('F')) { d = action('R'); if (d == 0) d = action('L'); } } return 0; }