結果
問題 | No.1298 OR XOR |
ユーザー | naskya |
提出日時 | 2020-11-27 21:50:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,063 bytes |
コンパイル時間 | 1,995 ms |
コンパイル使用メモリ | 194,024 KB |
最終ジャッジ日時 | 2025-01-16 06:57:05 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:56:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 56 | scanf("%d", &N); | ~~~~~^~~~~~~~~~
ソースコード
#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 endregionvoid 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();}