제출 #685298

#제출 시각아이디문제언어결과실행 시간메모리
685298grossly_overconfident버섯 세기 (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; vector<int> decipher(int a, int b, int c) { vector<int> m = { a, 0, b, c }; int c1 = use_machine(m); if (c1 == 0) { m = { 0, 0, 0 }; return m; } if (c1 == 3) { m = { 1, 1, 0 }; return m; } if (c1 == 2) { m = { b, a, 0, c }; c1 = use_machine(m); if (c1 == 1) { m = { 0, 1, 0 }; } else if (c1 == 3) { m = { 1, 0, 1 }; } else if (c1 == 2) { m = { 1, 1, 1 }; } return m; } m = { b, 0, c }; c1 = use_machine(m); if (c1 == 0) { m = { 1, 0, 0 }; } else if (c1 == 1) { m = { 0, 0, 1 }; } else if (c1 == 2) { m = { 0, 1, 1 }; } return m; } int count_mushrooms(int n) { int count = 0; int i = 0; while (i + 2 <= n - 1) { vector<int> take = decipher(i, i + 1, i + 2); if (take[0] == 0) { ++count; } if (take[1] == 0) { ++count; } if (take[2] == 0) { ++count; } i += 3; } if ((n - 1) % 3 == 1) { if (use_machine({ n - 1, 0 }) == 0) { ++count; } } if ((n - 1) % 3 == 2) { int take2 = use_machine({ n - 1, 0, n - 2 }) if (take2 == 0) { count += 2; } else if (take2 == 1) { ++count; } } return count; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:67:3: error: expected ',' or ';' before 'if'
   67 |   if (take2 == 0) {
      |   ^~
mushrooms.cpp:66:7: warning: unused variable 'take2' [-Wunused-variable]
   66 |   int take2 = use_machine({ n - 1, 0, n - 2 })
      |       ^~~~~
mushrooms.cpp:70:3: error: expected '}' before 'else'
   70 |   else if (take2 == 1) {
      |   ^~~~
mushrooms.cpp:65:24: note: to match this '{'
   65 |  if ((n - 1) % 3 == 2) {
      |                        ^
mushrooms.cpp:70:12: error: 'take2' was not declared in this scope
   70 |   else if (take2 == 1) {
      |            ^~~~~
mushrooms.cpp:73:2: warning: no return statement in function returning non-void [-Wreturn-type]
   73 |  }
      |  ^
mushrooms.cpp: At global scope:
mushrooms.cpp:74:2: error: expected unqualified-id before 'return'
   74 |  return count;
      |  ^~~~~~
mushrooms.cpp:75:1: error: expected declaration before '}' token
   75 | }
      | ^