Submission #19821

# Submission time Handle Problem Language Result Execution time Memory
19821 2016-02-25T05:57:26 Z xhae 동전 (kriii4_E) C++14
0 / 100
2 ms 2748 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

const int mmod = 1000000007;

int prv[256][512]; // successive previous H, current grundy
int nxt[256][512];

int main()
{
  int n;
  cin >> n;

  vector<int> grundy(1);
  grundy[0] = 0;
  for (int i=1; i<=n; i++) {
    set<int> nxt;
    for (int remain=0; remain<=i; remain++)
      for (int i=0; i<=remain; i++)
        nxt.insert(grundy[i] ^ grundy[remain - i]);
    int ii = 0;
    while (nxt.find(ii) != nxt.end()) ii ++;
    grundy.push_back(ii);
  }

//  for (int i=0; i<=n; i++) printf("%d ", grundy[i]);
//  printf("\n");

  prv[0][0] = 1;
  
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=i; j++)
      for (int k=0; k<512; k++) {
        if (i < n) {
          // H
          nxt[j+1][k] = (nxt[j+1][k] + prv[j][k]) % mmod;
        }
        {
          // T
          nxt[0][k^grundy[j]] = (nxt[0][k^grundy[j]] + prv[j][k]) % mmod;
        }
      }

    for (int j=0; j<256; j++)
      for (int k=0; k<512; k++) prv[j][k] = nxt[j][k], nxt[j][k] = 0;
  }

  printf("%d\n", prv[0][0]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 1 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
4 Correct 2 ms 2748 KB Output is correct
5 Correct 0 ms 2748 KB Output is correct
6 Correct 2 ms 2748 KB Output is correct
7 Correct 0 ms 2748 KB Output is correct
8 Incorrect 0 ms 2748 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -