제출 #1002207

#제출 시각아이디문제언어결과실행 시간메모리
1002207werty783죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <string> using namespace std; string to_ternary(int a) { if (a == 0) return "0"; // Special case for zero string ternary = ""; // Initialize an empty string for ternary representation while (a != 0) { int remainder = a % 3; ternary = to_string(remainder) + ternary; // Build the ternary string in reverse order a = floor(a / 3); // Integer division by 3 } return ternary; } int policz(int tab, int kwota) { int decipher[28] = {0, 1, 2, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27}; int cipher[28] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 16, 17, 18, 19, 20, 21, 22}; int deciphered_tab = decipher[tab]; cout << deciphered_tab << '\n'; if (kwota == 0) { if (deciphered_tab % 2 == 0) {return 0;} else {return 1;} } else { int bag = 0 ? (deciphered_tab % 2 == 0) : 1; int chosen_bag = 0; string kwota_in_ternary = to_ternary(kwota); int idx_to_compare = (deciphered_tab % 10) - 1; cout << idx_to_compare << endl; int value_to_compare = ((deciphered_tab/10) % 10); cout << value_to_compare << endl; cout << kwota_in_ternary[idx_to_compare] << endl; char char_to_compare = kwota_in_ternary[idx_to_compare]; int kwota_to_compare = char_to_compare - '0'; if (idx_to_compare == 7) { if (kwota_to_compare == 2) { if (bag == 0) { chosen_bag = -1; } else { chosen_bag = -2; } return chosen_bag; } else if (kwota_to_compare == 0) { if (bag == 0) { chosen_bag = -1; } else { chosen_bag = -2; } return chosen_bag; } else { return cipher[18]; } } if (kwota_to_compare > value_to_compare) { if (bag == 0) { chosen_bag = -2; } else { chosen_bag = -1; } return chosen_bag; } else if (kwota_to_compare < value_to_compare) { if (bag == 0) { chosen_bag = -1; } else { chosen_bag = -2; } return chosen_bag; } else { char next_kwota_char = kwota_in_ternary[idx_to_compare+1]; int next_kwota_int = next_kwota_char - '0'; int result = 10*next_kwota_int + idx_to_compare + 2; return cipher[result]; } } } vector<vector<int>> devise_strategy(int N) { vector<vector<int>> strategy; for (int i = 0; i < 22; i++) { for (int j = 0; j < N; j++) { strategy[i].push_back(policz(i, j)); } } return (strategy); }

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

prison.cpp: In function 'std::string to_ternary(int)':
prison.cpp:16:13: error: 'floor' was not declared in this scope
   16 |         a = floor(a / 3); // Integer division by 3
      |             ^~~~~