#define PROBLEM_NAME "sheffer"
#define TEST_STR "%03d"
#include "gentools.h"

#include <cstring>
#include <set>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <functional>
#include <algorithm>

#ifdef WIN32
#define INT64 "%I64d"
#else
#define INT64 "%lld"
#endif

#ifdef DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif


using namespace std;

vector<string> a;
int k;

const int MINN = 1, MAXN = 20, MAXK = 20, MAXL = 100;

void do_nothing (void) {
}

void open_test (void) {
  a.clear ();
  k = -1;
}

void close_test (void) {
}

void log_test (void) {
  //fprintf (flog, "n = %d", n);
}

void shuffle_test (void) {
  do_nothing ();
}

void verify_test (void) {
  do_nothing ();
}

void output_test (void) {
  ofstream o (cur_test_str);
  o << a.size() << " " << k << endl;
  for (int i = 0; i < (int) a.size(); i++) {
    o << a[i] << endl;
  }
}

string mult (const string s, int n) {
  string z;
  for (int i = 0; i < n; i++) {
    z += s;
  }
  return z;
}

void gen_random (int _n, int _k, int maxl) {
  START_TEST ("random(n:%d, k:%d, maxl:%d)", _n, _k, maxl);
  k = _k;
  a.resize (_n);
  for (int i = 0; i < _n; i++) {
    string s = "";
    int l = rndvalue (1, maxl);
    for (int j = 0; j < l; j++) {
      s += rndvalue (0, 1) ? 'W' : 'B';
    }
    a[i] = s;
  }
  END_TEST ();
}

void gen_samples (void) {
  START_TEST ("1st example");
  k = 2;
  a.resize (2);
  a[0] = "W";
  a[1] = "W";
  END_TEST ();
  START_TEST ("2nd example");
  k = 5;
  a.resize (2);
  a[0] = "W";
  a[1] = "B";
  END_TEST ();
}

void gen_small (void) {
  gen_random (1, 1, 1);
  gen_random (1, 2, 1);
}

void gen_medium () {
  for (int k = 3; k <= 10; k++) {
    gen_random (k, k, MAXL / 5);
  }
}

void gen_large (void) {
  int i, n;
  for (n = 1; n <= 5; n++) {
    gen_random (n, MAXK, MAXL);
  }
  for (n = MAXN - 5; n <= MAXN; n++) {
    gen_random (n, MAXK, MAXL);
  }

  START_TEST ("large: opponent play almost white (maximize answer)");
  k = MAXK;
  string w = mult ("W", MAXL);
  for (i = 0; i < MAXN; i++) {
    a.push_back (w);
  }
  END_TEST ();
  
  START_TEST ("large: one opponent");
  k = MAXK;
  a.push_back ("W");
  END_TEST ();

}

void stress () {
}

int main (int argc, char * argv []) {
  init_gen (argc, argv);
  
  //stress ();
  
  gen_samples ();
  gen_small ();
  gen_medium ();
  gen_large ();
  
  exit_gen ();

  return 0;
}
