제출 #385462

#제출 시각아이디문제언어결과실행 시간메모리
385462BlancaHMCoins (IOI17_coins)C++14
컴파일 에러
0 ms0 KiB
#include "coins.h" using namespace std; vector<int> coin_flips(vector<int> b, int c) { vector<int> flips(); int xor = 0; for (int i = 0; i < (int) b.size(); i++) { if (b[i]) xor ^= i; } if (xor == c) flips.push_back(0); else flips.push_back(xor^c); return flips; } int find_coin(vector<int> b) { int xor = 0; for (int i = 0; i < (int) b.size(); i++) { if (b[i]) xor ^= i; } return xor; }

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

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:6:9: error: expected unqualified-id before 'xor' token
    6 |     int xor = 0;
      |         ^~~
coins.cpp:8:19: error: expected primary-expression before 'xor' token
    8 |         if (b[i]) xor ^= i;
      |                   ^~~
coins.cpp:8:23: error: expected primary-expression before '^=' token
    8 |         if (b[i]) xor ^= i;
      |                       ^~
coins.cpp:10:9: error: expected primary-expression before 'xor' token
   10 |     if (xor == c)
      |         ^~~
coins.cpp:10:13: error: expected primary-expression before '==' token
   10 |     if (xor == c)
      |             ^~
coins.cpp:11:15: error: request for member 'push_back' in 'flips', which is of non-class type 'std::vector<int>()'
   11 |         flips.push_back(0);
      |               ^~~~~~~~~
coins.cpp:13:15: error: request for member 'push_back' in 'flips', which is of non-class type 'std::vector<int>()'
   13 |         flips.push_back(xor^c);
      |               ^~~~~~~~~
coins.cpp:13:25: error: expected primary-expression before 'xor' token
   13 |         flips.push_back(xor^c);
      |                         ^~~
coins.cpp:13:28: error: expected primary-expression before '^' token
   13 |         flips.push_back(xor^c);
      |                            ^
coins.cpp:14:12: error: could not convert 'flips' from 'std::vector<int>()' to 'std::vector<int>'
   14 |     return flips;
      |            ^~~~~
      |            |
      |            std::vector<int>()
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:18:9: error: expected unqualified-id before 'xor' token
   18 |     int xor = 0;
      |         ^~~
coins.cpp:20:19: error: expected primary-expression before 'xor' token
   20 |         if (b[i]) xor ^= i;
      |                   ^~~
coins.cpp:20:23: error: expected primary-expression before '^=' token
   20 |         if (b[i]) xor ^= i;
      |                       ^~
coins.cpp:22:12: error: expected primary-expression before 'xor' token
   22 |     return xor;
      |            ^~~
coins.cpp:22:15: error: expected primary-expression before ';' token
   22 |     return xor;
      |               ^