제출 #787810

#제출 시각아이디문제언어결과실행 시간메모리
787810borisAngelovCoins (IOI17_coins)C++17
컴파일 에러
0 ms0 KiB
#include "coins.h" #include <bits/stdc++.h> using namespace std; vector<int> coin_flips(vector<int> b, int c) { vector<int> result(1); int xor = c; for (int i = 0; i < b.size(); ++i) { if (b[i] != 0) { xor = (xor ^ b[i]); } } result[0] = xor; return result; } int find_coin(vector<int> b) { int ans = 0; for (int i = 0; i < b.size(); ++i) { if (b[i] != 0) { ans = (ans ^ b[i]); } } return ans; }

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

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:10:9: error: expected unqualified-id before 'xor' token
   10 |     int xor = c;
      |         ^~~
coins.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < b.size(); ++i)
      |                     ~~^~~~~~~~~~
coins.cpp:16:13: error: expected primary-expression before 'xor' token
   16 |             xor = (xor ^ b[i]);
      |             ^~~
coins.cpp:16:17: error: expected primary-expression before '=' token
   16 |             xor = (xor ^ b[i]);
      |                 ^
coins.cpp:16:20: error: expected primary-expression before 'xor' token
   16 |             xor = (xor ^ b[i]);
      |                    ^~~
coins.cpp:16:24: error: expected primary-expression before '^' token
   16 |             xor = (xor ^ b[i]);
      |                        ^
coins.cpp:20:17: error: expected primary-expression before 'xor' token
   20 |     result[0] = xor;
      |                 ^~~
coins.cpp:20:20: error: expected primary-expression before ';' token
   20 |     result[0] = xor;
      |                    ^
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < b.size(); ++i)
      |                     ~~^~~~~~~~~~