제출 #635146

#제출 시각아이디문제언어결과실행 시간메모리
635146marvinthang죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
/************************************* * author: marvinthang * * created: 25.08.2022 20:38:19 * *************************************/ #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define div ___div #define left ___left #define right ___right #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define MASK(i) (1LL << (i)) #define FULL(i) (MASK(i) - 1) #define BIT(x, i) ((x) >> (i) & 1) #define __builtin_popcount __builtin_popcountll #define scan_op(...) istream & operator >> (istream &in, __VA_ARGS__ &u) #define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u) #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); } template <class T> scan_op(vector <T>) { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; } template <class T> print_op(vector <T>) { out << '{'; for (size_t i = 0; i + 1 < u.size(); ++i) out << u[i] << ", "; if (!u.empty()) out << u.back(); return out << '}'; } template <class U, class V> scan_op(pair <U, V>) { return in >> u.fi >> u.se; } template <class U, class V> print_op(pair <U, V>) { return out << '(' << u.fi << ", " << u.se << ')'; } const double PI = 3.1415926535897932384626433832795; // acos(-1.0); atan(-1.0); const int dir[] = {1, 0, -1, 0, 1, 1, -1, -1, 1}; // {2, 1, -2, -1, -2, 1, 2, -1, 2}; const int NUM_BIT = 13; const int NUM_STATE = NUM_BIT * 2 + 1; pair <int, int> decode(int code) { --code; if (code < 0) return make_pair(0, 0); return make_pair(NUM_BIT - code / 2 - 1, code % 2); } int encode(int bit, int t) { if (bit < 0) return 0; return (NUM_BIT - bit - 1) * 2 + t + 1; } vector <vector <int>> devise_strategy(int n) { vector <vector <int>> res(NUM_STATE, vector<int> (n + 1, 0)); for (int state = 0; state < NUM_STATE; ++state) { if (!state) { res[state][0] = 0; for (int i = 1; i <= n; ++i) res[state][i] = encode(NUM_BIT - 1, BIT(NUM_BIT - 1, 0)); continue; } auto [bit, t] = decode(state); bool parity = bit & 1; res[state][0] = !parity; for (int i = 1; i <= n; ++i) { int pre_bit = t; int cur_bit = BIT(i, bit); if (pre_bit < cur_bit) res[state][i] = parity ? -2 : -1; else if (pre_bit > cur_bit) res[state][i] = parity ? -1 : -2; else res[state][i] = encode(bit - 1, BIT(i, bit - 1)); } } return res; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr); file("ioi22_day1_prison"); // int n; cin >> n; // vector <vector <int>> res = devise_strategy(n); // for (int i = 0; i < NUM_STATE; ++i) { // cout << decode(i) << ": "; // cout << res[i][0] << ' '; // for (int j = 1; j <= n; ++j) // if (res[i][j] >= 0) cout << decode(res[i][j]) << ' '; else cout << res[i][j] << ' '; // cout << '\n'; // } cerr << "Time elapsed: " << TIME << " s.\n"; return (0^0); }

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

prison.cpp: In function 'int main()':
prison.cpp:22:69: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 | #define          file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:71:2: note: in expansion of macro 'file'
   71 |  file("ioi22_day1_prison");
      |  ^~~~
prison.cpp:22:103: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 | #define          file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                                                               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:71:2: note: in expansion of macro 'file'
   71 |  file("ioi22_day1_prison");
      |  ^~~~
/usr/bin/ld: /tmp/cciMR4OP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccth9jFP.o:prison.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status