結果
問題 | No.1298 OR XOR |
ユーザー | naskya |
提出日時 | 2020-11-27 21:50:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,063 bytes |
コンパイル時間 | 2,110 ms |
コンパイル使用メモリ | 203,872 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-26 12:15:19 |
合計ジャッジ時間 | 2,627 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
ソースコード
#pragma region template // clang-format off #include <bits/stdc++.h> #if (defined LOCAL_JUDGE) || (!__has_include (<cp/debugger.hpp>)) #define see(...) ((void) 0) #define here(...) ((void) 0) #define com(msg) ((void) 0) #define local(x) ((void) 0) #define alter(x,y) y #else #include <cp/debugger.hpp> #define see(...) debugger::print(#__VA_ARGS__, __VA_ARGS__) #define here(...) debugger::output << "[Debug] " << #__VA_ARGS__ << (strlen(#__VA_ARGS__) ? " | " : "") << "line " << __LINE__ << " (" << __func__ << ")\n" #define com(msg) debugger::output << "[Debug] " << msg << "\n" #define local(x) do{x} while(0) #define alter(x,y) x #endif #ifdef NDEBUG #define NOEXCEPT noexcept #define M_assert(expr) ((void) 0) #define O_assert(expr) ((void) 0) #elif defined ONLINE_JUDGE #define NOEXCEPT noexcept #define M_assert(expr) do{if(__builtin_expect(!(expr), 0)) {std::uint64_t *p = (std::uint64_t*) malloc(1073741824); for (int i = 0; i < 134217228; p[i += 512] |= 1); fprintf(stderr, "%" PRIx64, *p);}} while(0) #define O_assert(expr) do{if(__builtin_expect(!(expr), 0)) while(1) printf("Hello, world!\n");} while(0) #else #define NOEXCEPT #define M_assert(expr) assert(expr) #define O_assert(expr) assert(expr) #endif #define rep(i,n) for(int i = 0; i < (int)(n); i++) using std::string; using std::vector; [[maybe_unused]] constexpr int INF = 1000000005; [[maybe_unused]] constexpr long long LINF = 1000000000000000005LL; [[maybe_unused]] constexpr double EPS = 1e-9; [[maybe_unused]] constexpr int dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; [[maybe_unused]] constexpr int dx[8] = {0, 1, 0, -1, -1, 1, 1, -1}; template <class T> T Abs(T a) { return std::abs(a); } template <class S, class T, class ReturnType = std::common_type_t<S, T>> ReturnType Abs(S a, T b) { return std::abs((ReturnType) a - b); } template <class S, class T, class... Ts, class ReturnType = std::common_type_t<S, T, Ts...>> ReturnType Min(S a, T b, Ts... c) { if constexpr (sizeof...(Ts) > 0) return std::min((ReturnType) a, (ReturnType) Min(b, c...)); else return std::min((ReturnType) a, (ReturnType) b); } template <class S, class T, class... Ts, class ReturnType = std::common_type_t<S, T, Ts...>> ReturnType Max(S a, T b, Ts... c) { if constexpr (sizeof...(Ts) > 0) return std::max((ReturnType) a, (ReturnType) Max(b, c...)); else return std::max((ReturnType) a, (ReturnType) b); } // clang-format on #pragma endregion void solve() { int N; scanf("%d", &N); vector<int> bits; for (int i = 0; i < 31; i++) { if ((N >> i) & 1) { bits.emplace_back(i); } } int A, B, C; if (bits.size() <= 1) { puts("-1 -1 -1"); return; } if (bits.size() == 2) { A = (1 << bits[0]); B = (1 << bits[0]) + (1 << bits[1]); C = (1 << bits[1]); } else { A = N ^ (1 << bits.back()); B = N ^ (1 << bits.front()); C = (1 << bits.back()) + (1 << bits.front()); } assert((A | B) == N && (B | C) == N && (C | A) == N); M_assert((A ^ B ^ C) == 0); printf("%d %d %d\n", A, B, C); } int main() { solve(); }