제출 #1212054

#제출 시각아이디문제언어결과실행 시간메모리
1212054doublepunCoins (IOI17_coins)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define endl "\n" using namespace std; string contoBin(int n) { ios::sync_with_stdio(false); cin.tie(0); string ans = ""; for (int r = 0;r < 6;r++) { stringstream ss; string pre; ss << (n%2); ss >> pre; ans+=pre; n = floor(n/2); } reverse(ans.begin(),ans.end()); return ans; } int[] coin_flips(int[] b, int c) { string code = contoBin(c); for (int i = 0;i < 6;i++) { stringstream ss2; int temp; ss2 << code[i]; ss2 >> temp; if (b[i] != temp) { b[i] = temp; } } return b; } int find_coin(int[] b) { return ((b[0]*pow(2,5) + b[1]*pow(2,4) + b[2]*pow(2,3) + b[3]*pow(2,2) + b[4]*2 + b[5])); } int main() { int T; cin >> T; while (T--) { int curse; cin >> curse; int broad[64]; for (int i = 0;i < 64;i++) { int state; cin >> state; broad[i] = state; } cout << find_coin(coin_flips(broad,curse)) << endl; } }

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

coins.cpp:21:4: error: structured binding declaration cannot have type 'int'
   21 | int[] coin_flips(int[] b, int c)
      |    ^~
coins.cpp:21:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
coins.cpp:21:4: error: empty structured binding declaration
coins.cpp:21:7: error: expected initializer before 'coin_flips'
   21 | int[] coin_flips(int[] b, int c)
      |       ^~~~~~~~~~
coins.cpp:37:21: error: expected ',' or '...' before 'b'
   37 | int find_coin(int[] b)
      |                     ^
coins.cpp: In function 'int find_coin(int*)':
coins.cpp:39:18: error: 'b' was not declared in this scope
   39 |         return ((b[0]*pow(2,5) + b[1]*pow(2,4) + b[2]*pow(2,3) + b[3]*pow(2,2) + b[4]*2 + b[5]));
      |                  ^
coins.cpp: In function 'int main()':
coins.cpp:58:35: error: 'coin_flips' was not declared in this scope
   58 |                 cout << find_coin(coin_flips(broad,curse)) << endl;
      |                                   ^~~~~~~~~~