Skip to content

Instantly share code, notes, and snippets.

@viliml
Created July 11, 2018 18:15
Show Gist options
  • Save viliml/29098c3b2cd9f14abfc15942da5254e7 to your computer and use it in GitHub Desktop.
Save viliml/29098c3b2cd9f14abfc15942da5254e7 to your computer and use it in GitHub Desktop.
#include "question.h"
using namespace std;
// Dummy implmenentation.
// No communication between two namespaces please.
namespace PlayerA
{
int arr[13] = {1, 1, 2, 3, 6, 10, 20, 35, 70, 126, 252, 462, 924};
const int MAXN = 1000;
int s[MAXN];
void InitA(int n)
{
int m;
for (m = 0; arr[m] < n; ++m);
for (int x = 0, i = 0; x < (1<<m); ++x) if (__builtin_popcount(x) == m / 2)
{
s[i++] = x;
}
}
int Shout(int x, int y)
{
--x, --y;
return 1 + __builtin_ctz(s[x] & ~s[y]);
}
}; // namespace PlayerA
namespace PlayerB
{
int arr[13] = {1, 1, 2, 3, 6, 10, 20, 35, 70, 126, 252, 462, 924};
const int MAXN = 1000;
int s[MAXN];
void InitB(int n)
{
int m;
for (m = 0; arr[m] < n; ++m);
for (int x = 0, i = 0; x < (1<<m); ++x) if (__builtin_popcount(x) == m / 2)
{
s[i++] = x;
}
}
int Answer(int q, int h)
{
--q, --h;
return !!(s[q] & 1<<h);
}
}; // namespace PlayerB
// Do not modity
void InitA(int N) {
PlayerA::InitA(N);
}
int Shout(int x, int y) {
return PlayerA::Shout(x, y);
}
void InitB(int N) {
PlayerB::InitB(N);
}
int Answer(int q, int h) {
return PlayerB::Answer(q, h);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment