제출 #1040918

#제출 시각아이디문제언어결과실행 시간메모리
1040918erray로봇 대회 (IOI23_robot)C++17
컴파일 에러
0 ms0 KiB
#include "robot.h" #include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "/home/ioi/contests/ioi23_d2/debug.h" #else #define debug(...) void(37) #endif int Z = 5; enum { BOUNDARY = -2, OBSTACLE = -1, CLEAN = 0, PATH = 1, WEST = 2, SOUTH = 3, EAST = 4, NORTH = 5 }; using I = pair<int, char>; I invalid{-1, 'Ğ'}; I get_instruction(int m, int w, int s, int e, int n) { auto Adj = [&](int x) { return (w == x) + (s == x) + (e == x) + (n == x); }; auto Next = [&] -> I { int start = (m >= WEST ? m - WEST + 1 : 0); for (int i = 0; i < 4; ++i) { int cur = WEST + (start + i) % 4; if (cur == WEST && w == EAST) { return {WEST, 'W'}; } if (cur == SOUTH && s == NORTH) { return {SOUTH, 'S'}; } if (cur == EAST && e == WEST) { return {EAST, 'E'}; } if (cur == NORTH && n == SOUTH) { return {NORTH, 'N'}; } } return invalid; }; auto Next_and_explore = [&] -> I { int start = (m >= WEST ? m - WEST + 1 : 0); for (int i = 0; i < 4; ++i) { int cur = WEST + (start + i) % 4; if (cur == WEST && (w == EAST || w == CLEAN)) { return {WEST, 'W'}; } if (cur == SOUTH && (s == NORTH || s == CLEAN)) { return {SOUTH, 'S'}; } if (cur == EAST && (e == WEST || e == CLEAN)) { return {EAST, 'E'}; } if (cur == NORTH && (n == SOUTH || n == CLEAN)) { return {NORTH, 'N'}; } } return invalid; }; auto Clean = [&] -> I { if (m == WEST) return {CLEAN, 'W'}; if (m == SOUTH) return {CLEAN, 'S'}; if (m == EAST) return {CLEAN, 'E'}; if (m == NORTH) return {CLEAN, 'N'}; return invalid; }; auto Path = [&] -> I { if (m == WEST) return {PATH, 'W'}; if (m == SOUTH) return {PATH, 'S'}; if (m == EAST) return {PATH, 'E'}; if (m == NORTH) return {PATH, 'N'}; return invalid; }; auto Is_betrayal = [&] { if (m == WEST && w != EAST) return true; if (m == SOUTH && s != NORTH) return true; if (m == EAST && e != WEST) return true; if (m == NORTH && n != SOUTH) return true; return false; }; if (m < 0) return invalid; // 0 0 if (n == BOUNDARY && w == BOUNDARY) { if (m == CLEAN) { if (s == CLEAN) { return {SOUTH, 'S'}; } if (e == CLEAN) { return {EAST, 'E'}; } return invalid; } if (Is_betrayal()) { auto n = Next(); if (n == invalid) return Path(); else { n.first = m; return n; } } } // N - 1 N - 1 if (s == BOUNDARY && e == BOUNDARY) { if (m == CLEAN) { auto go = Next(); if (go == invalid) return invalid; go.first = EAST; //betrayal return go; } else { return {PATH, 'T'}; } } //newly explored if (m == CLEAN) { return Next(); } //start cleaning and painting if (Is_betrayal()) { auto n = Next(); if (n == invalid) { if (Adj(PATH)) return Path(); else return Clean(); } else { n.first = m; return n; } } //explore return Next_and_explore(); } void program_pulibot() { for (int me = -2; me <= Z; ++me) { for (int w = -2; w <= Z; ++w) { for (int s = -2; s <= Z; ++s) { for (int e = -2; e <= Z; ++e) { for (int n = -2; n <= Z; ++n) { auto i = get_instruction(me, w, s, e, n); if (i != invalid) { set_instruction({me, w, s, e, n}, i.first, i.second); } } } } } } }

컴파일 시 표준 에러 (stderr) 메시지

robot.cpp:25:15: warning: multi-character character constant [-Wmultichar]
   25 | I invalid{-1, 'Ğ'};
      |               ^~~
robot.cpp: In lambda function:
robot.cpp:30:19: error: expected '{' before '->' token
   30 |   auto Next = [&] -> I {
      |                   ^~
robot.cpp: In function 'I get_instruction(int, int, int, int, int)':
robot.cpp:30:19: error: base operand of '->' has non-pointer type 'get_instruction(int, int, int, int, int)::<lambda()>'
robot.cpp: In lambda function:
robot.cpp:49:31: error: expected '{' before '->' token
   49 |   auto Next_and_explore = [&] -> I {
      |                               ^~
robot.cpp: In function 'I get_instruction(int, int, int, int, int)':
robot.cpp:49:31: error: base operand of '->' has non-pointer type 'get_instruction(int, int, int, int, int)::<lambda()>'
robot.cpp: In lambda function:
robot.cpp:69:20: error: expected '{' before '->' token
   69 |   auto Clean = [&] -> I {
      |                    ^~
robot.cpp: In function 'I get_instruction(int, int, int, int, int)':
robot.cpp:69:20: error: base operand of '->' has non-pointer type 'get_instruction(int, int, int, int, int)::<lambda()>'
robot.cpp: In lambda function:
robot.cpp:76:19: error: expected '{' before '->' token
   76 |   auto Path = [&] -> I {
      |                   ^~
robot.cpp: In function 'I get_instruction(int, int, int, int, int)':
robot.cpp:76:19: error: base operand of '->' has non-pointer type 'get_instruction(int, int, int, int, int)::<lambda()>'