結果
問題 | No.3083 12歳 |
ユーザー | FF256grhy |
提出日時 | 2021-03-30 07:52:00 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 3,800 bytes |
コンパイル時間 | 1,217 ms |
コンパイル使用メモリ | 102,688 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-07 12:03:36 |
合計ジャッジ時間 | 8,638 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 1 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 1 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 1 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 1 ms
5,376 KB |
testcase_46 | AC | 1 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 1 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 1 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 1 ms
5,376 KB |
testcase_53 | AC | 1 ms
5,376 KB |
testcase_54 | AC | 1 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 1 ms
5,376 KB |
testcase_58 | AC | 1 ms
5,376 KB |
testcase_59 | AC | 1 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | AC | 1 ms
5,376 KB |
testcase_62 | AC | 1 ms
5,376 KB |
testcase_63 | AC | 1 ms
5,376 KB |
testcase_64 | AC | 1 ms
5,376 KB |
testcase_65 | AC | 2 ms
5,376 KB |
testcase_66 | AC | 1 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 1 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
testcase_71 | AC | 1 ms
5,376 KB |
testcase_72 | AC | 1 ms
5,376 KB |
testcase_73 | AC | 1 ms
5,376 KB |
testcase_74 | AC | 1 ms
5,376 KB |
testcase_75 | AC | 1 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 1 ms
5,376 KB |
testcase_78 | AC | 1 ms
5,376 KB |
testcase_79 | AC | 1 ms
5,376 KB |
testcase_80 | AC | 2 ms
5,376 KB |
testcase_81 | AC | 2 ms
5,376 KB |
testcase_82 | AC | 2 ms
5,376 KB |
testcase_83 | AC | 2 ms
5,376 KB |
testcase_84 | AC | 1 ms
5,376 KB |
testcase_85 | AC | 1 ms
5,376 KB |
testcase_86 | AC | 2 ms
5,376 KB |
testcase_87 | AC | 2 ms
5,376 KB |
testcase_88 | AC | 2 ms
5,376 KB |
testcase_89 | AC | 1 ms
5,376 KB |
testcase_90 | AC | 1 ms
5,376 KB |
testcase_91 | AC | 1 ms
5,376 KB |
testcase_92 | AC | 1 ms
5,376 KB |
testcase_93 | AC | 2 ms
5,376 KB |
testcase_94 | AC | 2 ms
5,376 KB |
testcase_95 | AC | 2 ms
5,376 KB |
testcase_96 | AC | 2 ms
5,376 KB |
testcase_97 | AC | 2 ms
5,376 KB |
testcase_98 | AC | 2 ms
5,376 KB |
testcase_99 | AC | 2 ms
5,376 KB |
testcase_100 | AC | 2 ms
5,376 KB |
testcase_101 | AC | 1 ms
5,376 KB |
testcase_102 | AC | 1 ms
5,376 KB |
testcase_103 | AC | 2 ms
5,376 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | AC | 1 ms
5,376 KB |
testcase_106 | AC | 1 ms
5,376 KB |
testcase_107 | AC | 2 ms
5,376 KB |
testcase_108 | AC | 1 ms
5,376 KB |
testcase_109 | AC | 2 ms
5,376 KB |
testcase_110 | AC | 2 ms
5,376 KB |
testcase_111 | AC | 2 ms
5,376 KB |
testcase_112 | AC | 1 ms
5,376 KB |
testcase_113 | AC | 2 ms
5,376 KB |
testcase_114 | AC | 2 ms
5,376 KB |
testcase_115 | AC | 2 ms
5,376 KB |
testcase_116 | AC | 1 ms
5,376 KB |
testcase_117 | AC | 1 ms
5,376 KB |
testcase_118 | AC | 1 ms
5,376 KB |
testcase_119 | AC | 2 ms
5,376 KB |
testcase_120 | AC | 1 ms
5,376 KB |
testcase_121 | AC | 1 ms
5,376 KB |
testcase_122 | AC | 1 ms
5,376 KB |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 1 ms
5,376 KB |
testcase_125 | AC | 2 ms
5,376 KB |
testcase_126 | AC | 1 ms
5,376 KB |
testcase_127 | AC | 1 ms
5,376 KB |
testcase_128 | AC | 1 ms
5,376 KB |
testcase_129 | AC | 1 ms
5,376 KB |
testcase_130 | AC | 2 ms
5,376 KB |
testcase_131 | AC | 1 ms
5,376 KB |
testcase_132 | AC | 2 ms
5,376 KB |
testcase_133 | AC | 2 ms
5,376 KB |
testcase_134 | AC | 1 ms
5,376 KB |
testcase_135 | AC | 2 ms
5,376 KB |
testcase_136 | AC | 0 ms
5,376 KB |
testcase_137 | AC | 2 ms
5,376 KB |
testcase_138 | AC | 1 ms
5,376 KB |
testcase_139 | AC | 1 ms
5,376 KB |
testcase_140 | AC | 1 ms
5,376 KB |
testcase_141 | AC | 2 ms
5,376 KB |
testcase_142 | AC | 2 ms
5,376 KB |
testcase_143 | AC | 2 ms
5,376 KB |
testcase_144 | AC | 2 ms
5,376 KB |
testcase_145 | AC | 2 ms
5,376 KB |
testcase_146 | AC | 2 ms
5,376 KB |
testcase_147 | AC | 2 ms
5,376 KB |
testcase_148 | AC | 1 ms
5,376 KB |
testcase_149 | AC | 1 ms
5,376 KB |
testcase_150 | AC | 2 ms
5,376 KB |
testcase_151 | AC | 2 ms
5,376 KB |
testcase_152 | AC | 1 ms
5,376 KB |
testcase_153 | AC | 2 ms
5,376 KB |
testcase_154 | AC | 1 ms
5,376 KB |
testcase_155 | AC | 1 ms
5,376 KB |
testcase_156 | AC | 2 ms
5,376 KB |
testcase_157 | AC | 2 ms
5,376 KB |
testcase_158 | AC | 1 ms
5,376 KB |
testcase_159 | AC | 2 ms
5,376 KB |
testcase_160 | AC | 1 ms
5,376 KB |
testcase_161 | AC | 2 ms
5,376 KB |
testcase_162 | AC | 2 ms
5,376 KB |
testcase_163 | AC | 1 ms
5,376 KB |
testcase_164 | AC | 1 ms
5,376 KB |
testcase_165 | AC | 2 ms
5,376 KB |
testcase_166 | AC | 1 ms
5,376 KB |
testcase_167 | AC | 2 ms
5,376 KB |
testcase_168 | AC | 2 ms
5,376 KB |
testcase_169 | AC | 2 ms
5,376 KB |
testcase_170 | AC | 1 ms
5,376 KB |
testcase_171 | AC | 2 ms
5,376 KB |
testcase_172 | AC | 1 ms
5,376 KB |
testcase_173 | AC | 1 ms
5,376 KB |
testcase_174 | AC | 2 ms
5,376 KB |
testcase_175 | AC | 2 ms
5,376 KB |
testcase_176 | AC | 1 ms
5,376 KB |
testcase_177 | AC | 2 ms
5,376 KB |
testcase_178 | AC | 2 ms
5,376 KB |
testcase_179 | AC | 2 ms
5,376 KB |
testcase_180 | AC | 1 ms
5,376 KB |
testcase_181 | AC | 2 ms
5,376 KB |
testcase_182 | AC | 1 ms
5,376 KB |
testcase_183 | AC | 1 ms
5,376 KB |
testcase_184 | AC | 2 ms
5,376 KB |
testcase_185 | AC | 2 ms
5,376 KB |
testcase_186 | AC | 2 ms
5,376 KB |
testcase_187 | AC | 2 ms
5,376 KB |
testcase_188 | AC | 2 ms
5,376 KB |
testcase_189 | AC | 2 ms
5,376 KB |
testcase_190 | AC | 2 ms
5,376 KB |
testcase_191 | AC | 2 ms
5,376 KB |
testcase_192 | AC | 2 ms
5,376 KB |
testcase_193 | AC | 2 ms
5,376 KB |
testcase_194 | AC | 1 ms
5,376 KB |
testcase_195 | AC | 1 ms
5,376 KB |
testcase_196 | AC | 2 ms
5,376 KB |
testcase_197 | AC | 2 ms
5,376 KB |
testcase_198 | AC | 2 ms
5,376 KB |
testcase_199 | AC | 1 ms
5,376 KB |
testcase_200 | AC | 2 ms
5,376 KB |
testcase_201 | AC | 2 ms
5,376 KB |
testcase_202 | AC | 2 ms
5,376 KB |
testcase_203 | AC | 2 ms
5,376 KB |
testcase_204 | AC | 1 ms
5,376 KB |
testcase_205 | AC | 2 ms
5,376 KB |
testcase_206 | AC | 2 ms
5,376 KB |
testcase_207 | AC | 2 ms
5,376 KB |
testcase_208 | AC | 2 ms
5,376 KB |
testcase_209 | AC | 1 ms
5,376 KB |
testcase_210 | AC | 2 ms
5,376 KB |
testcase_211 | AC | 1 ms
5,376 KB |
testcase_212 | AC | 1 ms
5,376 KB |
testcase_213 | AC | 2 ms
5,376 KB |
testcase_214 | AC | 1 ms
5,376 KB |
testcase_215 | AC | 2 ms
5,376 KB |
testcase_216 | AC | 2 ms
5,376 KB |
testcase_217 | AC | 2 ms
5,376 KB |
testcase_218 | AC | 1 ms
5,376 KB |
testcase_219 | AC | 1 ms
5,376 KB |
testcase_220 | AC | 2 ms
5,376 KB |
testcase_221 | AC | 2 ms
5,376 KB |
testcase_222 | AC | 1 ms
5,376 KB |
testcase_223 | AC | 1 ms
5,376 KB |
testcase_224 | AC | 2 ms
5,376 KB |
testcase_225 | AC | 2 ms
5,376 KB |
testcase_226 | AC | 1 ms
5,376 KB |
testcase_227 | AC | 2 ms
5,376 KB |
testcase_228 | AC | 2 ms
5,376 KB |
testcase_229 | AC | 1 ms
5,376 KB |
testcase_230 | AC | 2 ms
5,376 KB |
testcase_231 | AC | 2 ms
5,376 KB |
testcase_232 | AC | 2 ms
5,376 KB |
testcase_233 | AC | 2 ms
5,376 KB |
testcase_234 | AC | 1 ms
5,376 KB |
testcase_235 | AC | 1 ms
5,376 KB |
testcase_236 | AC | 1 ms
5,376 KB |
testcase_237 | AC | 2 ms
5,376 KB |
testcase_238 | AC | 2 ms
5,376 KB |
testcase_239 | AC | 1 ms
5,376 KB |
testcase_240 | AC | 2 ms
5,376 KB |
testcase_241 | AC | 2 ms
5,376 KB |
testcase_242 | AC | 1 ms
5,376 KB |
testcase_243 | AC | 2 ms
5,376 KB |
testcase_244 | AC | 1 ms
5,376 KB |
testcase_245 | AC | 2 ms
5,376 KB |
testcase_246 | AC | 2 ms
5,376 KB |
testcase_247 | AC | 1 ms
5,376 KB |
testcase_248 | AC | 1 ms
5,376 KB |
testcase_249 | AC | 2 ms
5,376 KB |
testcase_250 | AC | 1 ms
5,376 KB |
testcase_251 | AC | 1 ms
5,376 KB |
testcase_252 | AC | 2 ms
5,376 KB |
testcase_253 | AC | 2 ms
5,376 KB |
testcase_254 | AC | 2 ms
5,376 KB |
testcase_255 | AC | 2 ms
5,376 KB |
testcase_256 | AC | 2 ms
5,376 KB |
testcase_257 | AC | 1 ms
5,376 KB |
testcase_258 | AC | 2 ms
5,376 KB |
testcase_259 | AC | 2 ms
5,376 KB |
testcase_260 | AC | 2 ms
5,376 KB |
testcase_261 | AC | 2 ms
5,376 KB |
testcase_262 | AC | 2 ms
5,376 KB |
testcase_263 | AC | 2 ms
5,376 KB |
testcase_264 | AC | 1 ms
5,376 KB |
testcase_265 | AC | 2 ms
5,376 KB |
testcase_266 | AC | 1 ms
5,376 KB |
testcase_267 | AC | 2 ms
5,376 KB |
testcase_268 | AC | 2 ms
5,376 KB |
testcase_269 | AC | 1 ms
5,376 KB |
testcase_270 | AC | 1 ms
5,376 KB |
testcase_271 | AC | 1 ms
5,376 KB |
testcase_272 | AC | 2 ms
5,376 KB |
testcase_273 | AC | 1 ms
5,376 KB |
testcase_274 | AC | 1 ms
5,376 KB |
testcase_275 | AC | 2 ms
5,376 KB |
testcase_276 | AC | 2 ms
5,376 KB |
testcase_277 | AC | 2 ms
5,376 KB |
testcase_278 | AC | 2 ms
5,376 KB |
testcase_279 | AC | 2 ms
5,376 KB |
testcase_280 | AC | 2 ms
5,376 KB |
testcase_281 | AC | 1 ms
5,376 KB |
testcase_282 | AC | 2 ms
5,376 KB |
testcase_283 | AC | 2 ms
5,376 KB |
testcase_284 | AC | 2 ms
5,376 KB |
testcase_285 | AC | 2 ms
5,376 KB |
testcase_286 | AC | 1 ms
5,376 KB |
testcase_287 | AC | 1 ms
5,376 KB |
testcase_288 | AC | 1 ms
5,376 KB |
testcase_289 | AC | 2 ms
5,376 KB |
testcase_290 | AC | 2 ms
5,376 KB |
testcase_291 | AC | 1 ms
5,376 KB |
testcase_292 | AC | 2 ms
5,376 KB |
testcase_293 | AC | 2 ms
5,376 KB |
testcase_294 | AC | 1 ms
5,376 KB |
testcase_295 | AC | 1 ms
5,376 KB |
testcase_296 | AC | 1 ms
5,376 KB |
testcase_297 | AC | 2 ms
5,376 KB |
testcase_298 | AC | 2 ms
5,376 KB |
testcase_299 | AC | 2 ms
5,376 KB |
testcase_300 | AC | 2 ms
5,376 KB |
testcase_301 | AC | 2 ms
5,376 KB |
testcase_302 | AC | 2 ms
5,376 KB |
testcase_303 | AC | 1 ms
5,376 KB |
testcase_304 | AC | 1 ms
5,376 KB |
testcase_305 | AC | 2 ms
5,376 KB |
testcase_306 | AC | 2 ms
5,376 KB |
testcase_307 | AC | 1 ms
5,376 KB |
testcase_308 | AC | 2 ms
5,376 KB |
testcase_309 | AC | 1 ms
5,376 KB |
testcase_310 | AC | 2 ms
5,376 KB |
testcase_311 | AC | 2 ms
5,376 KB |
testcase_312 | AC | 2 ms
5,376 KB |
testcase_313 | AC | 2 ms
5,376 KB |
testcase_314 | AC | 2 ms
5,376 KB |
testcase_315 | AC | 2 ms
5,376 KB |
testcase_316 | AC | 2 ms
5,376 KB |
testcase_317 | AC | 1 ms
5,376 KB |
testcase_318 | AC | 1 ms
5,376 KB |
testcase_319 | AC | 2 ms
5,376 KB |
testcase_320 | AC | 1 ms
5,376 KB |
testcase_321 | AC | 2 ms
5,376 KB |
testcase_322 | AC | 1 ms
5,376 KB |
testcase_323 | AC | 2 ms
5,376 KB |
testcase_324 | AC | 1 ms
5,376 KB |
testcase_325 | AC | 2 ms
5,376 KB |
testcase_326 | AC | 1 ms
5,376 KB |
testcase_327 | AC | 1 ms
5,376 KB |
testcase_328 | AC | 2 ms
5,376 KB |
testcase_329 | AC | 2 ms
5,376 KB |
testcase_330 | AC | 2 ms
5,376 KB |
testcase_331 | AC | 2 ms
5,376 KB |
testcase_332 | AC | 2 ms
5,376 KB |
testcase_333 | AC | 2 ms
5,376 KB |
testcase_334 | AC | 1 ms
5,376 KB |
testcase_335 | AC | 1 ms
5,376 KB |
testcase_336 | AC | 1 ms
5,376 KB |
testcase_337 | AC | 1 ms
5,376 KB |
testcase_338 | AC | 1 ms
5,376 KB |
testcase_339 | AC | 1 ms
5,376 KB |
testcase_340 | AC | 2 ms
5,376 KB |
testcase_341 | AC | 1 ms
5,376 KB |
testcase_342 | AC | 2 ms
5,376 KB |
testcase_343 | AC | 1 ms
5,376 KB |
testcase_344 | AC | 2 ms
5,376 KB |
testcase_345 | AC | 1 ms
5,376 KB |
testcase_346 | AC | 2 ms
5,376 KB |
testcase_347 | AC | 1 ms
5,376 KB |
testcase_348 | AC | 1 ms
5,376 KB |
testcase_349 | AC | 2 ms
5,376 KB |
testcase_350 | AC | 2 ms
5,376 KB |
testcase_351 | AC | 1 ms
5,376 KB |
testcase_352 | AC | 1 ms
5,376 KB |
testcase_353 | AC | 2 ms
5,376 KB |
testcase_354 | AC | 1 ms
5,376 KB |
testcase_355 | AC | 2 ms
5,376 KB |
testcase_356 | AC | 1 ms
5,376 KB |
testcase_357 | AC | 2 ms
5,376 KB |
testcase_358 | AC | 2 ms
5,376 KB |
testcase_359 | AC | 2 ms
5,376 KB |
testcase_360 | AC | 1 ms
5,376 KB |
testcase_361 | AC | 1 ms
5,376 KB |
testcase_362 | AC | 1 ms
5,376 KB |
testcase_363 | AC | 1 ms
5,376 KB |
testcase_364 | AC | 2 ms
5,376 KB |
testcase_365 | AC | 1 ms
5,376 KB |
ソースコード
#include <iostream> #include <string> #include <vector> #include <functional> // std::function #include <algorithm> // std::count // 作りかけの validation 用ライブラリ namespace validate { using LL = long long int; using CC = std::function<bool(char)>; using S = std::string; namespace char_class { bool upper(char c) { return ('A' <= c && c <= 'Z'); } bool lower(char c) { return ('a' <= c && c <= 'z'); } bool digit(char c) { return ('0' <= c && c <= '9'); } bool alpha(char c) { return (upper(c) || lower(c)); } bool alnum(char c) { return (alpha(c) || digit(c)); } bool digit_or_minus(char c) { return (digit(c) || c == '-'); } CC of(S const & s) { return [&](char c) { return (std::count(s.begin(), s.end(), c) > 0); }; } } namespace internal { bool is_end = false; S input_while(CC ok) { S s; while(true) { char c = std::cin.get(); if(ok(c)) { s += c; } else { std::cin.unget(); break; } } return s; } bool is_positive_integer(S const & s) { if(s == "" || s[0] == '0') { return false; } for(char c: s) { if(! char_class::digit(c)) { return false; } } return true; } bool is_integer(S const & s) { if(s == "") { return false; } if(s == "0") { return true; } return is_positive_integer(s.substr(s[0] == '-' ? 1 : 0)); } } S tag_def = "[?]"; S tag_sep = " --> "; void check(bool p, S tag = tag_def) { if(! p) { std::cerr << "[!] Validation error: " << tag << std::endl; internal::is_end = true; exit(1); } } void input_equal(S s, S tag = tag_def) { tag += tag_sep + __func__; for(char c: s) { check(std::cin.get() == c, tag); } } LL get_int(LL mi, LL ma, S term, S tag = tag_def) { tag += tag_sep + __func__; auto s = internal::input_while(char_class::digit_or_minus); check(internal::is_integer(s), tag + " (is_integer)"); LL n = stoll(s); check(mi <= n && n <= ma, tag + " (range)"); input_equal(term, tag + " (term)"); return n; } std::vector<LL> get_vector_int(int n, LL mi, LL ma, S sep, S term, S tag = tag_def) { tag += tag_sep + __func__; check(0 <= n, tag + " (n: non-negative)"); std::vector<LL> v; while(static_cast<int>(v.size()) < n) { auto tag_i = tag + " ([" + std::to_string(v.size()) + "])"; v.push_back(get_int(mi, ma, "", tag_i)); if(static_cast<int>(v.size()) < n) { input_equal(sep, tag_i + " (sep)"); } } input_equal(term, tag + " (term)"); return v; } S get_string(int n, CC ok, S term, S tag = tag_def) { tag += tag_sep + __func__ + " by length"; check(0 <= n, tag + " (n: non-negative)"); S s; while(static_cast<int>(s.size()) < n) { s += std::cin.get(); check(ok(s.back()), tag + " (char_class)"); } input_equal(term, tag + " (term)"); return s; } S get_string(CC ok, int mi, int ma, S term, S tag = tag_def) { tag += tag_sep + __func__ + " by char_class"; auto s = internal::input_while(ok); check(mi <= static_cast<int>(s.size()) && static_cast<int>(s.size()) <= ma, tag + " (length)"); input_equal(term, tag + " (term)"); return s; } void input_end(S tag = tag_def) { tag += tag_sep + __func__; input_equal({ EOF }, tag); internal::is_end = true; } namespace internal { struct End { ~ End() { check(is_end, "Missing validate::input_end()."); } } end_; } } // ---- int main() { auto Y = validate::get_int(2000, 3000 - 1, " "); auto N = validate::get_int(1, 365, " "); auto D = validate::get_int(1, 365, "\n"); validate::input_end(); auto c = [](int y) -> int { return 365 + (y % 4 != 0 || (y % 100 == 0 && y % 400 != 0) ? 0 : 1); }; if(D > 333) { D += c(Y - 12) - c(Y + 1); } int mi = N - std::min(N, D), ma = std::min(N, c(Y - 12) - D); validate::check(0 <= mi && mi <= ma && ma <= N); std::cout << mi << " " << ma << std::endl; } // validation