結果
| 問題 |
No.474 色塗り2
|
| コンテスト | |
| ユーザー |
anta
|
| 提出日時 | 2016-12-24 00:28:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 1,521 bytes |
| コンパイル時間 | 1,742 ms |
| コンパイル使用メモリ | 168,116 KB |
| 実行使用メモリ | 11,244 KB |
| 最終ジャッジ日時 | 2024-12-14 17:06:04 |
| 合計ジャッジ時間 | 2,164 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
unsigned inv2adic(unsigned x) {
unsigned i = x, p;
do {
p = i * x;
i *= 2U - p;
} while (p != 1);
return i;
}
inline int popcount(unsigned x) {
#ifdef __GNUC__
return __builtin_popcount(x);
#else
return _mm_popcnt_u32(x);
#endif
}
int main() {
int T;
scanf("%d", &T);
const int N = 2000000;
vector<unsigned> fact(N + 1);
fact[0] = 1;
rep(i, N) {
unsigned x = i + 1;
while ((x & 1) == 0) x >>= 1;
fact[i + 1] = fact[i] * x;
}
for (int ii = 0; ii < T; ++ii) {
int A; int B; int C;
scanf("%d%d%d", &A, &B, &C);
//C(C(c+b-1,b) * c + a - 1, a) * c
int n = C + B - 1, r = B;
int val = 0;
val -= popcount(n);
val += popcount(r);
val += popcount(n - r);
unsigned x = fact[n] * inv2adic(fact[r] * fact[n - r]);
x <<= min(val, 30);
x *= C;
x += A - 1;
int ans = (A & ~x) == 0 && C % 2 == 1 ? 1 : 0;
printf("%d\n", ans);
}
return 0;
}
anta