Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* e002 */
- /* AC (5ms, 304KB) */
- #include <cstdio>
- #include <cstring>
- #define max(x,y) ((x) > (y) ? (x) : (y))
- #define min(x,y) ((x) < (y) ? (x) : (y))
- using namespace std;
- const int MAXGAME = 10005;
- int N, M, ans, l ,r, sgValue[MAXGAME];
- int SG(int x)
- {
- if(sgValue[x] != -1) return sgValue[x];
- bool vis[MAXGAME - 4]{};
- for(int i = 1; i <= M; i++)
- if(x >= i) vis[SG(x - i)] = true;
- for(int i = 0; i < MAXGAME; i++)
- if(!vis[i]) return sgValue[x] = i;
- }
- int main()
- {
- while(~scanf("%d %d", &N, &M))
- {
- memset(sgValue, -1, sizeof(int) * MAXGAME);
- ans = sgValue[0] = 0;
- for(int i = 0; i < N && scanf("%d %d", &l, &r); i++)
- ans ^= SG(r - l - 1);
- if(ans) puts("OpenChan");
- else puts("Kitty");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment