結果

問題 No.5003 物理好きクリッカー
ユーザー tailstails
提出日時 2018-12-19 17:07:59
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 19,900 bytes
コンパイル時間 844 ms
実行使用メモリ 22,404 KB
スコア 0
平均クエリ数 1.00
最終ジャッジ日時 2021-12-04 02:24:07
合計ジャッジ時間 13,938 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void init()’:
main.cpp:403:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  gets(events);
             ^
In file included from main.cpp:2:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
main.cpp:403:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  gets(events);
             ^
In file included from main.cpp:2:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
main.cpp: In member function ‘bool Solver::runto(int)’:
main.cpp:255:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^
/tmp/ccKqxc8w.o: In function `init()':
main.cpp:(.text+0xef): warning: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <map>

typedef long long cookie_t;

char const fnames[][16]={"hand","lily","factory","casino","grimoire"};
cookie_t const bspeeds[]={1,10,120,2000,25000};
cookie_t const bprices[]={150,2000,30000,600000,10000000};

cookie_t pricess[11][64];

char range[][22]={
{1,2,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   0
{1,2,  0, 1, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   1
{2,2,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   2
{2,2,  1, 3, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   3
{2,2,  2, 4, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   4
{2,2,  3, 5, 0,1,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   5
{2,2,  4, 6, 0,1,  0, 1, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   6
{2,2,  4, 7, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   7
{2,2,  5, 7, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   8
{2,2,  5, 8, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //   9
{2,2,  5, 9, 0,1,  0, 3, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  10
{2,2,  6,10, 1,1,  0, 3, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  11
{2,2,  6,10, 1,1,  0, 4, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  12
{2,3,  7,10, 1,1,  0, 4, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  13
{2,3,  7,10, 1,1,  1, 5, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  14
{2,3,  8,11, 1,1,  2, 6, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  15
{2,3,  8,11, 1,1,  2, 6, 0,0,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  16
{2,3,  8,11, 1,1,  3, 6, 0,1,  0, 0, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  17
{2,3,  9,12, 1,1,  3, 7, 0,1,  0, 1, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  18
{2,3,  9,12, 1,1,  4, 7, 0,1,  0, 1, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  19
{2,3,  9,12, 1,1,  4, 8, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  20
{2,3,  9,13, 1,1,  5, 8, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  21
{2,3,  9,13, 1,1,  5, 9, 0,1,  0, 2, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  22
{2,3, 10,13, 1,1,  5, 9, 0,1,  0, 3, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  23
{2,3, 10,13, 1,1,  5, 9, 0,1,  0, 3, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  24
{2,3, 10,13, 1,1,  6, 9, 0,1,  0, 4, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  25
{2,3, 10,14, 1,1,  7,10, 0,1,  0, 4, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  26
{3,3, 10,14, 1,2,  7,10, 0,1,  0, 5, 0,0,  0, 0, 0,0,  0, 0, 0,0, }, //  27
{3,3, 10,15, 1,2,  7,10, 1,1,  1, 5, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  28
{3,3, 10,15, 1,2,  7,10, 1,1,  1, 6, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  29
{3,3, 10,15, 1,2,  8,10, 1,1,  1, 6, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  30
{3,3, 11,16, 1,2,  8,10, 1,1,  1, 7, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  31
{3,3, 11,16, 1,2,  9,10, 1,1,  2, 7, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  32
{3,3, 11,16, 1,2,  9,11, 1,1,  2, 7, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  33
{3,3, 12,16, 1,2,  9,11, 1,1,  2, 8, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  34
{3,3, 12,17, 1,2,  9,11, 1,1,  2, 8, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  35
{3,3, 12,17, 1,2,  9,12, 1,1,  3, 8, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  36
{3,3, 12,18, 1,2,  9,12, 1,1,  3, 8, 0,1,  0, 0, 0,0,  0, 0, 0,0, }, //  37
{3,3, 13,18, 1,2,  9,12, 1,1,  4, 8, 0,1,  0, 1, 0,0,  0, 0, 0,0, }, //  38
{3,3, 14,18, 1,2,  9,12, 1,1,  4, 9, 0,1,  0, 1, 0,0,  0, 0, 0,0, }, //  39
{3,3, 14,19, 2,2,  9,13, 1,1,  4, 9, 0,1,  0, 2, 0,0,  0, 0, 0,0, }, //  40
{3,3, 14,19, 2,2,  9,13, 1,1,  5, 9, 0,1,  0, 2, 0,0,  0, 0, 0,0, }, //  41
{3,3, 14,19, 2,2, 10,13, 1,1,  5, 9, 0,1,  0, 3, 0,0,  0, 0, 0,0, }, //  42
{3,3, 15,19, 2,2, 10,13, 1,1,  5,10, 0,1,  0, 3, 0,0,  0, 0, 0,0, }, //  43
{3,3, 15,19, 2,2, 10,14, 1,1,  6,10, 0,1,  0, 4, 0,0,  0, 0, 0,0, }, //  44
{3,3, 16,19, 2,2, 10,14, 1,2,  7,10, 0,1,  0, 4, 0,0,  0, 0, 0,0, }, //  45
{3,3, 16,19, 2,2, 10,14, 1,2,  7,10, 1,1,  0, 4, 0,0,  0, 0, 0,0, }, //  46
{3,3, 16,20, 2,2, 10,14, 1,2,  7,10, 1,1,  0, 5, 0,0,  0, 0, 0,0, }, //  47
{3,3, 16,20, 2,2, 10,14, 1,2,  8,10, 1,1,  0, 5, 0,0,  0, 0, 0,0, }, //  48
{3,3, 16,20, 2,2, 10,14, 1,2,  8,11, 1,1,  0, 5, 0,0,  0, 0, 0,0, }, //  49
{3,3, 16,20, 2,2, 10,15, 1,2,  8,11, 1,1,  0, 6, 0,0,  0, 0, 0,0, }, //  50
{3,3, 16,21, 2,2, 11,16, 1,2,  8,11, 1,1,  1, 6, 0,1,  0, 0, 0,0, }, //  51
{3,3, 16,21, 2,2, 11,16, 1,2,  8,12, 1,1,  1, 7, 0,1,  0, 0, 0,0, }, //  52
{3,3, 16,21, 2,2, 12,16, 1,2,  8,12, 1,1,  1, 8, 0,1,  0, 0, 0,0, }, //  53
{3,3, 17,21, 2,2, 12,17, 1,2,  8,12, 1,1,  2, 8, 0,1,  0, 0, 0,0, }, //  54
{3,3, 17,21, 2,2, 12,17, 1,2,  9,12, 1,1,  2, 8, 0,1,  0, 1, 0,0, }, //  55
{3,3, 17,21, 2,2, 12,17, 1,2,  9,12, 1,1,  2, 9, 0,1,  0, 1, 0,0, }, //  56
{3,3, 17,21, 2,2, 12,17, 1,2,  9,12, 1,1,  3, 9, 0,1,  0, 1, 0,0, }, //  57
{3,3, 17,21, 2,2, 13,17, 1,2,  9,13, 1,1,  3, 9, 0,1,  0, 1, 0,0, }, //  58
{3,3, 17,22, 2,2, 13,17, 1,2,  9,13, 1,1,  3, 9, 0,1,  0, 2, 0,0, }, //  59
{3,3, 17,22, 2,2, 13,18, 1,2,  9,13, 1,1,  3, 9, 0,1,  0, 2, 0,0, }, //  60
{3,3, 18,22, 2,2, 13,18, 1,2,  9,13, 1,1,  4, 9, 0,1,  0, 2, 0,0, }, //  61
{3,3, 18,22, 2,2, 13,18, 1,2,  9,13, 1,1,  4, 9, 0,1,  0, 2, 0,0, }, //  62
{3,3, 18,22, 2,2, 13,18, 1,2,  9,13, 1,1,  5,10, 0,1,  0, 3, 0,0, }, //  63
{3,3, 19,23, 2,2, 14,18, 1,2,  9,13, 1,1,  5,10, 0,1,  0, 3, 0,0, }, //  64
{3,3, 19,23, 2,2, 14,19, 1,2,  9,14, 1,1,  5,10, 0,1,  0, 4, 0,0, }, //  65
{3,3, 19,23, 2,2, 14,19, 2,2,  9,14, 1,1,  5,10, 0,1,  0, 4, 0,0, }, //  66
{3,3, 19,24, 2,2, 14,19, 2,2, 10,14, 1,1,  5,10, 0,1,  0, 4, 0,0, }, //  67
{3,3, 19,24, 2,2, 14,19, 2,2, 10,15, 1,1,  6,11, 0,1,  0, 4, 0,0, }, //  68
{3,3, 19,24, 2,2, 14,19, 2,2, 10,15, 1,2,  6,11, 0,1,  0, 5, 0,0, }, //  69
{3,3, 19,24, 2,2, 15,20, 2,2, 10,16, 1,2,  6,11, 0,1,  0, 5, 0,0, }, //  70
{3,3, 19,24, 2,2, 15,20, 2,2, 10,16, 1,2,  7,11, 1,1,  0, 5, 0,0, }, //  71
{3,3, 19,24, 2,2, 15,20, 2,2, 10,16, 1,2,  7,11, 1,1,  0, 6, 0,0, }, //  72
{3,3, 19,24, 2,2, 15,20, 2,2, 11,16, 1,2,  8,11, 1,1,  0, 6, 0,0, }, //  73
{3,3, 19,24, 2,2, 15,21, 2,2, 11,16, 1,2,  8,11, 1,1,  0, 6, 0,0, }, //  74
{3,3, 19,24, 2,2, 15,21, 2,2, 11,17, 1,2,  8,11, 1,1,  0, 6, 0,1, }, //  75
{3,3, 19,24, 2,2, 15,21, 2,2, 11,17, 1,2,  8,11, 1,1,  1, 6, 0,1, }, //  76
{3,3, 19,24, 2,2, 16,21, 2,2, 11,17, 1,2,  8,12, 1,1,  1, 6, 0,1, }, //  77
{3,3, 19,24, 2,2, 16,21, 2,2, 11,17, 1,2,  8,12, 1,1,  1, 7, 0,1, }, //  78
{3,3, 19,24, 2,3, 16,21, 2,2, 12,18, 1,2,  9,12, 1,1,  1, 7, 0,1, }, //  79
{3,3, 19,24, 2,3, 16,21, 2,2, 12,18, 1,2,  9,12, 1,1,  2, 8, 0,1, }, //  80
{3,3, 19,24, 2,3, 16,21, 2,2, 13,18, 1,2,  9,13, 1,1,  2, 9, 0,1, }, //  81
{3,3, 19,24, 2,3, 16,22, 2,2, 13,18, 1,2,  9,13, 1,1,  2, 9, 0,1, }, //  82
{3,3, 19,24, 2,3, 16,22, 2,2, 13,19, 1,2,  9,13, 1,1,  3, 9, 0,1, }, //  83
{3,3, 19,24, 2,3, 17,22, 2,2, 13,19, 1,2, 10,14, 1,1,  3, 9, 0,1, }, //  84
{3,3, 19,25, 2,3, 17,22, 2,2, 13,19, 1,2, 10,14, 1,1,  3, 9, 0,1, }, //  85
{3,3, 19,25, 2,3, 18,22, 2,2, 14,19, 1,2, 10,14, 1,2,  3,10, 0,1, }, //  86
{3,4, 20,25, 2,3, 18,22, 2,2, 14,19, 1,2, 10,14, 1,2,  3,10, 0,1, }, //  87
{3,4, 21,26, 2,3, 18,22, 2,2, 14,19, 1,2, 10,14, 1,2,  3,10, 0,1, }, //  88
{3,4, 21,26, 2,3, 18,22, 2,2, 14,19, 1,2, 10,14, 1,2,  4,10, 0,1, }, //  89
{3,4, 21,26, 2,3, 18,22, 2,2, 14,19, 1,2, 11,15, 1,2,  4,10, 0,1, }, //  90
{3,4, 21,26, 2,3, 18,23, 2,2, 15,19, 2,2, 11,15, 1,2,  5,10, 0,1, }, //  91
{3,4, 21,27, 2,3, 18,23, 2,2, 15,19, 2,2, 11,15, 1,2,  5,10, 0,1, }, //  92
{3,4, 21,27, 2,3, 18,23, 2,2, 15,19, 2,2, 11,16, 1,2,  5,10, 0,1, }, //  93
{3,4, 21,27, 2,3, 19,23, 2,2, 15,19, 2,2, 11,16, 1,2,  5,10, 0,1, }, //  94
{3,4, 21,27, 2,3, 19,23, 2,2, 15,19, 2,2, 11,16, 1,2,  6,10, 0,1, }, //  95
{3,4, 21,27, 2,3, 19,23, 2,2, 16,19, 2,2, 11,16, 1,2,  6,11, 0,1, }, //  96
{3,4, 21,27, 2,3, 19,23, 2,2, 16,19, 2,2, 11,17, 1,2,  7,11, 0,1, }, //  97
{3,4, 21,27, 2,3, 19,24, 2,2, 16,19, 2,2, 11,17, 1,2,  7,11, 0,1, }, //  98
{3,4, 21,27, 2,3, 19,24, 2,2, 16,19, 2,2, 11,17, 1,2,  7,12, 0,1, }, //  99
{3,4, 21,27, 2,3, 19,24, 2,2, 16,19, 2,2, 11,18, 1,2,  7,12, 0,1, }, // 100
{3,4, 21,27, 2,3, 19,24, 2,2, 16,20, 2,2, 11,18, 1,2,  7,12, 1,1, }, // 101
{3,4, 22,27, 2,3, 19,24, 2,2, 16,20, 2,2, 12,19, 1,2,  8,13, 1,1, }, // 102
{3,4, 22,28, 2,3, 19,24, 2,3, 16,20, 2,2, 12,19, 1,2,  8,14, 1,1, }, // 103
{3,4, 22,28, 2,3, 20,24, 2,3, 17,20, 2,2, 13,19, 1,2,  8,14, 1,1, }, // 104
{3,4, 22,28, 2,3, 20,24, 2,3, 17,21, 2,2, 13,19, 1,2,  9,14, 1,1, }, // 105
{3,4, 22,29, 2,3, 20,24, 2,3, 17,21, 2,2, 13,20, 1,2,  9,14, 1,1, }, // 106
{3,4, 22,29, 2,3, 20,25, 2,3, 17,21, 2,2, 13,20, 2,2,  9,15, 1,1, }, // 107
{3,4, 22,29, 2,3, 20,25, 2,3, 17,22, 2,2, 13,20, 2,2,  9,15, 1,1, }, // 108
{3,4, 22,29, 2,3, 20,25, 2,3, 17,22, 2,2, 14,20, 2,2, 10,16, 1,1, }, // 109
{3,4, 22,29, 2,3, 20,25, 2,3, 17,22, 2,2, 15,20, 2,2, 10,16, 1,1, }, // 110
{3,4, 22,29, 2,3, 20,25, 2,3, 17,22, 2,2, 15,20, 2,2, 10,16, 1,1, }, // 111
{3,4, 22,30, 2,3, 20,26, 2,3, 17,22, 2,3, 16,21, 2,2, 10,16, 1,1, }, // 112
{3,4, 22,30, 2,3, 20,27, 2,3, 18,22, 2,3, 16,21, 2,2, 11,16, 1,2, }, // 113
{3,4, 22,30, 2,3, 20,27, 2,3, 18,23, 2,3, 16,21, 2,2, 11,16, 1,2, }, // 114
{3,4, 23,30, 2,3, 20,27, 2,3, 18,23, 2,3, 17,21, 2,2, 11,17, 1,2, }, // 115
{3,4, 23,30, 2,3, 20,27, 2,3, 18,24, 2,3, 17,21, 2,2, 11,17, 1,2, }, // 116
{3,4, 23,30, 2,3, 20,28, 2,3, 18,24, 2,3, 17,21, 2,2, 12,17, 1,2, }, // 117
{3,4, 23,30, 2,3, 20,28, 2,3, 18,25, 2,3, 17,21, 2,2, 12,17, 1,2, }, // 118
{3,4, 23,30, 2,3, 20,28, 2,3, 18,25, 2,3, 18,21, 2,2, 12,17, 1,2, }, // 119
{3,4, 23,30, 2,3, 20,28, 2,3, 19,25, 2,3, 18,21, 2,2, 12,18, 1,2, }, // 120
{3,4, 23,30, 2,3, 21,28, 2,3, 19,25, 2,3, 18,22, 2,2, 12,18, 1,2, }, // 121
{3,4, 23,30, 2,3, 21,29, 2,3, 19,26, 2,3, 18,22, 2,2, 12,18, 1,2, }, // 122
{3,4, 23,30, 2,3, 21,30, 2,3, 19,26, 2,3, 18,22, 2,2, 12,18, 1,2, }, // 123
{3,4, 23,30, 2,3, 22,30, 2,3, 19,27, 2,3, 18,22, 2,2, 12,19, 1,2, }, // 124
{3,4, 23,31, 2,3, 22,30, 2,3, 19,27, 2,3, 18,22, 2,2, 12,20, 1,2, }, // 125
{3,4, 23,31, 2,3, 22,30, 2,3, 19,27, 2,3, 18,22, 2,2, 12,20, 1,2, }, // 126
{3,4, 23,31, 2,3, 22,30, 2,3, 19,27, 2,3, 18,22, 2,2, 12,20, 1,2, }, // 127
{3,4, 23,31, 2,4, 22,30, 2,3, 19,27, 2,3, 18,22, 2,2, 12,20, 1,2, }, // 128
{3,4, 23,32, 2,4, 22,31, 2,3, 20,28, 2,3, 18,23, 2,3, 12,20, 1,2, }, // 129
{3,4, 23,33, 2,4, 22,31, 2,3, 20,28, 2,3, 18,23, 2,3, 12,20, 1,2, }, // 130
{3,4, 23,34, 2,4, 23,31, 2,3, 20,28, 2,3, 18,23, 2,3, 12,20, 1,2, }, // 131
{3,4, 23,34, 3,4, 24,31, 3,3, 20,28, 2,3, 19,24, 2,3, 13,20, 1,2, }, // 132
{3,4, 23,34, 3,4, 24,31, 3,3, 20,28, 2,3, 19,24, 2,3, 13,20, 1,2, }, // 133
{3,4, 24,34, 3,4, 24,31, 3,3, 20,28, 2,3, 19,24, 2,3, 13,20, 1,2, }, // 134
{3,4, 24,34, 3,4, 24,31, 3,3, 21,28, 2,3, 19,24, 2,3, 13,21, 1,2, }, // 135
{3,4, 24,34, 3,4, 24,31, 3,3, 21,28, 2,3, 19,24, 2,3, 13,21, 1,2, }, // 136
{3,4, 25,34, 3,4, 25,31, 3,3, 22,28, 2,3, 19,24, 2,3, 13,21, 1,2, }, // 137
{3,4, 26,34, 3,4, 25,31, 3,3, 22,28, 2,3, 19,24, 2,3, 14,21, 1,2, }, // 138
{3,4, 26,34, 3,4, 25,31, 3,3, 22,29, 2,3, 19,25, 2,3, 14,21, 1,2, }, // 139
{3,4, 26,34, 3,4, 25,31, 3,3, 23,30, 2,3, 19,25, 2,3, 14,21, 1,2, }, // 140
{3,4, 26,34, 3,4, 25,31, 3,3, 23,30, 2,3, 19,26, 2,3, 14,21, 1,2, }, // 141
{3,4, 26,34, 3,4, 25,31, 3,3, 23,30, 2,3, 19,26, 2,3, 15,21, 1,2, }, // 142
{3,4, 26,34, 3,4, 25,31, 3,3, 23,30, 2,3, 19,27, 2,3, 15,21, 1,2, }, // 143
{3,4, 27,34, 3,4, 25,31, 3,3, 24,30, 2,3, 20,27, 2,3, 15,21, 1,2, }, // 144
{3,5, 27,34, 3,4, 25,31, 3,3, 24,30, 2,3, 20,27, 2,3, 16,21, 1,2, }, // 145
{3,5, 27,34, 3,4, 25,31, 3,3, 25,30, 2,3, 20,27, 2,3, 16,22, 1,2, }, // 146
{3,5, 27,34, 3,4, 25,31, 3,3, 25,30, 3,3, 21,27, 2,3, 17,22, 2,2, }, // 147
{3,5, 28,34, 3,4, 26,31, 3,3, 25,30, 3,3, 21,27, 2,3, 17,22, 2,2, }, // 148
{3,5, 29,34, 3,4, 26,31, 3,3, 25,30, 3,3, 21,27, 2,3, 18,22, 2,2, }, // 149
{3,5, 29,34, 3,4, 27,31, 3,3, 25,30, 3,3, 22,27, 2,3, 18,22, 2,2, }, // 150
{3,5, 29,34, 3,4, 27,31, 3,3, 25,30, 3,3, 22,27, 2,3, 19,22, 2,2, }, // 151
{3,5, 29,34, 3,4, 27,31, 3,3, 25,30, 3,3, 22,27, 2,3, 19,22, 2,2, }, // 152
{3,5, 29,34, 3,4, 28,31, 3,3, 26,30, 3,3, 23,28, 2,3, 19,22, 2,2, }, // 153
{3,5, 29,34, 3,4, 28,31, 3,3, 26,30, 3,3, 24,28, 2,3, 19,22, 2,2, }, // 154
{4,5, 30,35, 3,4, 28,31, 3,3, 26,30, 3,3, 24,28, 3,3, 19,22, 2,2, }, // 155
{4,5, 30,35, 3,4, 28,31, 3,3, 27,30, 3,3, 25,28, 3,3, 19,23, 2,2, }, // 156
{4,5, 30,35, 3,4, 29,31, 3,3, 27,30, 3,3, 25,28, 3,3, 20,23, 2,2, }, // 157
{4,5, 31,35, 3,4, 29,31, 3,3, 27,30, 3,3, 26,28, 3,3, 21,23, 2,2, }, // 158
{4,5, 31,35, 3,4, 29,31, 3,3, 27,30, 3,3, 26,28, 3,3, 21,23, 2,2, }, // 159
{4,5, 31,35, 3,4, 29,31, 3,3, 28,29, 3,3, 27,28, 3,3, 21,23, 2,2, }, // 160
{4,5, 32,35, 3,4, 29,31, 3,3, 28,29, 3,3, 27,28, 3,3, 21,23, 2,2, }, // 161
{5,5, 32,33, 3,3, 29,30, 3,3, 28,29, 3,3, 27,28, 3,3, 21,23, 2,2, }, // 162
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 163
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 164
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 165
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 166
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 167
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 168
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 169
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 170
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 171
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 172
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 173
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 174
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 175
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 176
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 177
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 178
{5,5, 33,33, 3,3, 30,30, 3,3, 29,29, 3,3, 28,28, 3,3, 23,23, 2,2, }, // 179
};

int n10000;
char events[10010];
int asale[10010];
int akoma[10010];
int abonus[10010];

struct N{
	char n[11]={0};
	char & operator[](int i){ return n[i]; }
};

bool operator<(N const & a, N const & b){
	return memcmp(a.n,b.n,11)<0;
}

struct Solver {
	bool final=false;
	char history[200];
	
	cookie_t cookie=0;
	cookie_t speed=0;
	cookie_t refundsum=0;
	cookie_t value=0;
	//double value=0;
	N n;
	int nsum=0;
	int nowsale=0;
	int nowfever=0;
	int turn=0;

	void output(char const * cmd, char const * arg=0){
		if(arg){
			dprintf(1,"%s %s\n",cmd,arg);
		}else{
			dprintf(1,"%s\n",cmd);
		}
	}

	bool runto(int to){
		assert(to<=n10000);
		assert(turn<=to);
		cookie_t speedall=speed+(cookie_t(1)<<n[0]);
		for(bool b=true;b;){
			int d=abonus[turn]+1;
			if(d>to-turn){
				d=to-turn;
				cookie+=(akoma[turn]-akoma[turn+d])*speedall;
				turn+=d;
				break;
			}else{
				cookie+=(akoma[turn]-akoma[turn+d])*speedall;
				turn+=d;
				cookie+=(cookie+99)/100;
			}
		}
		assert(turn==to);
	}

	bool step(int a){
		assert(a>=0&&a<11);
		bool finished=false;
		char const * cmd;
		char const * arg;
		cookie_t price1,price2,refund,delta;
		price1=pricess[a][n[a]];
		if(a==0){
			// enhclick
			refund=0;
			delta=cookie_t(1)<<n[0];
			cmd="enhclick";
			arg=0;
		}else{
			int i=a-1>>1;
			if(a&1){
				// buy
				refund=(price1+3)/4;
				delta=bspeeds[i]<<n[a+1];
				cmd="buy";
			}else{
				// reinforce
				refund=0;
				delta=bspeeds[i]*n[a-1]<<n[a];
				cmd="reinforce";
			}
			arg=fnames[i];
		}
		price2=price1-price1/10;

		cookie_t speedall=speed+(cookie_t(1)<<n[0]);
		int needkoma1=price1<=cookie?0:(price1-cookie+speedall-1)/speedall;
		int buyturn1=turn+needkoma1;
		if(buyturn1>=n10000){
			buyturn1=n10000-1;
		}
		if(akoma[turn]-akoma[buyturn1]-needkoma1>0){
			buyturn1-=(akoma[turn]-akoma[buyturn1]-needkoma1)*20;
			if(buyturn1<turn){
				buyturn1=turn;
			}
		}
		while(buyturn1<n10000 && akoma[turn]-akoma[buyturn1]<needkoma1){
			buyturn1+=1;
		}
		cookie_t gain1=cookie_t(-3e10);
		if(buyturn1<n10000){
			gain1=akoma[buyturn1]*delta+refund-price1;
		}
		
		int needkoma2=price2<=cookie?0:(price2-cookie+speedall-1)/speedall;
		int buyturn2=turn+needkoma2;
		if(buyturn2>=n10000){
			buyturn2=n10000-1;
		}
		if(akoma[turn]-akoma[buyturn2]-needkoma2>0){
			buyturn2-=(akoma[turn]-akoma[buyturn2]-needkoma2)*20;
			if(buyturn2<turn){
				buyturn2=turn;
			}
		}
		while(buyturn2<n10000 && akoma[turn]-akoma[buyturn2]<needkoma2){
			buyturn2+=1;
		}
		buyturn2+=asale[buyturn2];
		cookie_t gain2=cookie_t(-3e10);
		if(buyturn2<n10000){
			gain2=akoma[buyturn2]*delta+refund-price2;
		}

		if(gain1<0 && gain2<0){
			if(final){
				for(int i=turn;i<n10000-nsum;++i){
					output("click");
				}
			}
			runto(n10000-nsum);
			for(int i=0;i<5;){
				if(n[i*2+1]){
					n[i*2+1]-=1;
					cookie_t r=(pricess[i*2+1][n[i*2+1]]+3)/4;
					cookie+=r;
					refundsum-=r;
					speed-=bspeeds[i]<<n[i*2+2];
					if(final){
						output("sell",fnames[i]);
					}
					cookie+=(akoma[turn]-akoma[turn+1])*speed;
					if(events[turn]=='B'){
						cookie+=(cookie+99)/100;
					}
					turn+=1;
				}else{
					++i;
				}
			}
			assert(refundsum==0);
			assert(turn==n10000);
			value=cookie;
			finished=true;
		}else{
			int to=gain1+(akoma[buyturn1]-akoma[buyturn2])*delta/2>=gain2?buyturn1:buyturn2;
			if(final){
				for(int i=turn;i<to;++i){
					output("click");
				}
				output(cmd,arg);
			}
			runto(to);
			cookie-=events[turn-1]=='S'?price2:price1;
			assert(cookie>=0);
			n[a]+=1;
			if(a){
				nsum+=a&1;
				speed+=delta;
				refundsum+=refund;
			}

			cookie+=(akoma[turn]-akoma[turn+1])*speed;
			if(events[turn]=='B'){
				cookie+=(cookie+99)/100;
			}
			turn+=1;
			value=cookie+akoma[turn]*(speed+(cookie_t(1)<<n[0]))+refundsum;
			//value=(cookie+akoma[turn]*(speed+(cookie_t(1)<<n[0])))*exp(akoma[turn]*0.00001)+refundsum;
		}
		return finished;
	}
	
	void run(char const * acts) {
		while(!step(*acts++)){
		}
	}

};

void init(){
	for(int a=0;a<11;++a){
		cookie_t c;
		pricess[a][0]=c=a==0?15:a&1?bprices[a>>1]:pricess[a-1][0]*10;
		for(int j=1;j<64;++j){
			pricess[a][j]=c=a&1?c+(c+4)/5:c*10;
		}
	}

	scanf("%d ",&n10000);
	gets(events);

	int koma=0;
	int fever=0;
	int nextsale=n10000*2;
	int nextbonus=n10000*2;
	for(int turn=n10000;turn--;){
		if(events[turn]=='S'){
			nextsale=turn+1;
		}
		asale[turn]=nextsale-turn;
		if(events[turn]=='B'){
			nextbonus=turn;
		}
		abonus[turn]=nextbonus-turn;
		koma+=events[turn]=='F'?121:1;
	}
	for(int turn=0;turn<n10000;++turn){
		akoma[turn]=koma;
		koma-=fever?(--fever,7):1;
		if(events[turn]=='F'){
			fever=20;
		}
	}
}

cookie_t simulate(char * best_acts){
	std::map<N,Solver> map0,map1;

	{
		Solver s;
		map0[s.n]=s;
	}

	cookie_t best_cookie=0;
	Solver best_s;
	int acti=0;
	while(!map0.empty()){
		for(auto& x:map0){
			//assert(x.second.value<19000000000ll);
			for(int a=0;a<11;++a){
				Solver s=x.second;
				bool ok=true;
				s.n[a]+=1;
				for(int b=0;b<11;++b){
					if(s.n[b]<range[acti][b*2]||s.n[b]>range[acti][b*2+1]){
						ok=false;
						break;
					}
				}
				if(!s.n[1]&&s.n[2])ok=false;
				if(!s.n[3]&&s.n[4])ok=false;
				if(!s.n[5]&&s.n[6])ok=false;
				if(!s.n[7]&&s.n[8])ok=false;
				if(!s.n[9]&&s.n[10])ok=false;
				s.n[a]-=1;
				if(ok){
					s.history[acti]=a;
					if(!s.step(a)){
						auto it=map1.find(s.n);
						if(it==map1.end() || it->second.value<s.value){
							map1[s.n]=s;
						}
					}else{
						s.history[acti+1]=0xff;
						assert(s.turn==n10000);
						if(best_cookie<s.cookie){
							best_cookie=s.cookie;
							memcpy(best_acts,s.history,200);
						}
					}
				}
			}
		}
		++acti;
		map0=std::move(map1);
		map1.clear();
	}
	return best_cookie;
}

int main(){
	init();
	close(0);

	char best_acts[200];
	simulate(best_acts);

	{
		Solver s;
		s.final=true;
		s.run(best_acts);
	}
	return 0;
}
0