#include #include #include #include using namespace std; const string B = "1000000"; const string P = "0100000"; const string T = "0010000"; const string S = "0001000"; const string X = "0000100"; const string V = "0000010"; const string E = "0000001"; const string TP = "0110000"; const string SX = "0001100"; const string TV = "0010010"; const string PV = "0100010"; const string END = "0000000"; bool bernoulli(double x); void reber(string symb); void xvploop(string symb); void ends(string symb); void endv(string symb); int main(int argc, char* argv[]) { cout << "7 7" << endl; srand48(time(NULL)); for (int i = 0; i < 1000; ++i) { cout << B << " " << TP << endl; if (bernoulli(0.5)) { cout << T << " " << B << endl; reber(T); cout << T << " " << E << endl; cout << E << " " << END << endl; cout << "#end" << endl; } else { cout << P << " " << B << endl; reber(P); cout << P << " " << E << endl; cout << E << " " << END << endl; cout << "#end" << endl; } } cout << "#dataend" << endl; } void reber(string symb) { cout << B << " " << TP << endl; if (bernoulli(0.5)) { cout << T << " " << SX << endl; while (bernoulli(0.5)) cout << S << " " << SX << endl; cout << X << " " << SX << endl; xvploop(symb); } else { cout << P << " " << TV << endl; while (bernoulli(0.5)) cout << T << " " << TV << endl; cout << V << " " << PV << endl; if (bernoulli(0.5)) { cout << P << " " << SX << endl; xvploop(symb); } else endv(symb); } } void xvploop(string symb) { if (bernoulli(0.5)) { ends(symb); return; } cout << X << " " << TV << endl; while (bernoulli(0.5)) cout << T << " " << TV << endl; cout << V << " " << PV << endl; if (bernoulli(0.5)) { endv(symb); return; } cout << P << " " << SX << endl; xvploop(symb); return; } void ends(string symb) { cout << S << " " << E << endl; cout << E << " " << symb << endl; } void endv(string symb) { cout << V << " " << E << endl; cout << E << " " << symb << endl; } bool bernoulli(double x) { assert(x <= 1.0 && x >= 0.0); return drand48() > (1 - x); }