Created
July 11, 2018 18:15
-
-
Save viliml/29098c3b2cd9f14abfc15942da5254e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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