注:本题代码和思路均来自 std。
Description
给定若干句话,求每句话来自哪个文本。
Solution
数据分析题,我猜这题在 POI 2019 中就是用来骗分的,故加上了骗分标签。
因为截止到 2020.8.7 11:45 还没有一个人能写出正解(
这题一种解法就是小林子那种的打表解法,在这里介绍真正的数据分析解法。
首先,第一部分,我们对标点符号和数字进行分析,存一个数组 $Q$,$Q[i][\mathtt{c}]$ 就代表在第 $i$ 个文本字符 $\tt c$ 出现的概率。
剖析完之后得到的结果为
Q[0][' ']=0.15634;
Q[0][',']=0.02080;
Q[0]['.']=0.00655;
Q[0][';']=0.00333;
Q[0][':']=0.00267;
Q[0]['"']=0.00243;
Q[0]['!']=0.00239;
Q[0]['-']=0.00144;
Q[0]['?']=0.00099;
Q[0]['*']=0.00032;
Q[0][')']=0.00016;
Q[1][' ']=0.15888;
Q[1]['.']=0.02443;
Q[1][',']=0.01425;
Q[1]['-']=0.00767;
Q[1]['?']=0.00198;
Q[1]['!']=0.00160;
Q[1]['"']=0.00127;
Q[1][':']=0.00095;
Q[1][';']=0.00063;
Q[1][')']=0.00018;
Q[1]['0']=0.00003;
Q[1]['8']=0.00003;
Q[1]['\'']=0.00001;
Q[1]['5']=0.00001;
Q[1]['9']=0.00001;
Q[1]['6']=0.00001;
Q[1]['7']=0.00001;
Q[1]['4']=0.00001;
Q[2][' ']=0.15901;
Q[2][',']=0.01825;
Q[2]['.']=0.00963;
Q[2]['-']=0.00342;
Q[2]['!']=0.00126;
Q[2][':']=0.00107;
Q[2]['?']=0.00088;
Q[2]['"']=0.00075;
Q[2][';']=0.00020;
Q[2][')']=0.00002;
Q[2]['\'']=0.00000;
然后是对文本段的单词进行分析,因为是波兰语,所以不需要对每个字母进行概率分析(加上单词分析比字母分析更好)。
取出关键的波兰语词语,进行概率分析,与标点数字分析的原理一样,存一个 $M[i][\mathtt{s}]$ 的数组。
M[0]["w"]=0.0220758;
M[0]["sie"]=0.0219952;
M[0]["i"]=0.0207706;
M[0]["z"]=0.0181924;
M[0]["na"]=0.0169194;
M[0]["nie"]=0.0112957;
M[0]["I"]=0.0106189;
M[0]["do"]=0.0077185;
M[0]["ze"]=0.0073640;
M[0]["jak"]=0.0068161;
M[0]["to"]=0.0064133;
M[0]["A"]=0.0049630;
M[0]["po"]=0.0040284;
M[0]["za"]=0.0040284;
M[0]["o"]=0.0038189;
M[0]["juz"]=0.0034806;
M[0]["a"]=0.0032227;
M[0]["tak"]=0.0031744;
M[0]["co"]=0.0030616;
M[0]["od"]=0.0029327;
M[0]["W"]=0.0028844;
M[0]["ja"]=0.0026588;
M[0]["Na"]=0.0024654;
M[0]["Nie"]=0.0022881;
M[0]["byl"]=0.0022720;
M[0]["Z"]=0.0022398;
M[0]["Ze"]=0.0022237;
M[0]["jest"]=0.0021270;
M[0]["nim"]=0.0021109;
M[0]["mu"]=0.0020787;
M[0]["go"]=0.0020626;
M[0]["pan"]=0.0019981;
M[0]["Hrabia"]=0.0018531;
M[0]["Sedzia"]=0.0018370;
M[0]["rzekl"]=0.0018208;
M[0]["Ale"]=0.0017725;
M[0]["gdy"]=0.0017242;
M[0]["Bo"]=0.0017081;
M[0]["Jak"]=0.0017081;
M[0]["mnie"]=0.0016436;
M[0]["tylko"]=0.0016436;
M[0]["ich"]=0.0015953;
M[0]["Lecz"]=0.0015791;
M[0]["jako"]=0.0015469;
M[0]["pod"]=0.0015469;
M[0]["dla"]=0.0015147;
M[0]["tym"]=0.0014825;
M[0]["tam"]=0.0014180;
M[0]["Tadeusz"]=0.0013858;
M[0]["u"]=0.0013697;
M[0]["tu"]=0.0013536;
M[0]["nad"]=0.0013374;
M[0]["Wojski"]=0.0013213;
M[0]["bez"]=0.0013213;
M[0]["lecz"]=0.0013213;
M[0]["ten"]=0.0013213;
M[0]["To"]=0.0012891;
M[0]["jej"]=0.0012891;
M[0]["przez"]=0.0012569;
M[0]["przy"]=0.0012569;
M[0]["przed"]=0.0012408;
M[0]["jeszcze"]=0.0012246;
M[0]["on"]=0.0011924;
M[0]["Tak"]=0.0011763;
M[0]["bylo"]=0.0011763;
M[0]["ku"]=0.0011763;
M[0]["sam"]=0.0011763;
M[0]["Gdy"]=0.0011441;
M[0]["bo"]=0.0011280;
M[0]["ma"]=0.0011280;
M[0]["domu"]=0.0011118;
M[0]["Juz"]=0.0010957;
M[0]["mi"]=0.0010957;
M[0]["Ja"]=0.0010796;
M[0]["jego"]=0.0010796;
M[0]["mial"]=0.0010796;
M[0]["oczy"]=0.0010796;
M[0]["by"]=0.0010635;
M[0]["wszyscy"]=0.0010474;
M[0]["O"]=0.0010313;
M[0]["On"]=0.0010152;
M[0]["nas"]=0.0010152;
M[0]["te"]=0.0010152;
M[0]["czy"]=0.0009990;
M[0]["gdzie"]=0.0009990;
M[0]["Az"]=0.0009346;
M[0]["Gerwazy"]=0.0009185;
M[0]["tez"]=0.0009024;
M[0]["Co"]=0.0008863;
M[0]["Telimena"]=0.0008863;
M[0]["sobie"]=0.0008863;
M[0]["znowu"]=0.0008863;
M[0]["Czy"]=0.0008701;
M[0]["kto"]=0.0008701;
M[0]["az"]=0.0008540;
M[0]["rece"]=0.0008540;
M[0]["choc"]=0.0008379;
M[0]["glowy"]=0.0008379;
M[0]["szlachta"]=0.0008379;
M[0]["tej"]=0.0008379;
M[0]["we"]=0.0008379;
M[1]["sie"]=0.0276917;
M[1]["i"]=0.0266913;
M[1]["nie"]=0.0179453;
M[1]["w"]=0.0175207;
M[1]["na"]=0.0160956;
M[1]["ze"]=0.0153933;
M[1]["z"]=0.0147564;
M[1]["do"]=0.0122371;
M[1]["to"]=0.0089992;
M[1]["a"]=0.0079294;
M[1]["pan"]=0.0069290;
M[1]["Wokulski"]=0.0067453;
M[1]["o"]=0.0057817;
M[1]["za"]=0.0056306;
M[1]["co"]=0.0047242;
M[1]["ja"]=0.0046262;
M[1]["jest"]=0.0046262;
M[1]["jak"]=0.0046221;
M[1]["mu"]=0.0043404;
M[1]["ale"]=0.0043036;
M[1]["mnie"]=0.0041158;
M[1]["go"]=0.0039647;
M[1]["mi"]=0.0038749;
M[1]["pani"]=0.0038422;
M[1]["po"]=0.0037361;
M[1]["tak"]=0.0036585;
M[1]["od"]=0.0035931;
M[1]["juz"]=0.0034951;
M[1]["A"]=0.0032869;
M[1]["tylko"]=0.0032461;
M[1]["nawet"]=0.0032012;
M[1]["jej"]=0.0031807;
M[1]["Nie"]=0.0024335;
M[1]["W"]=0.0023805;
M[1]["Ale"]=0.0023355;
M[1]["tym"]=0.0023070;
M[1]["sobie"]=0.0022988;
M[1]["panna"]=0.0022947;
M[1]["ktory"]=0.0022743;
M[1]["jeszcze"]=0.0022580;
M[1]["jego"]=0.0022008;
M[1]["ma"]=0.0021151;
M[1]["panie"]=0.0020987;
M[1]["czy"]=0.0020620;
M[1]["I"]=0.0020252;
M[1]["dla"]=0.0020130;
M[1]["ten"]=0.0020130;
M[1]["on"]=0.0020089;
M[1]["Izabela"]=0.0019844;
M[1]["moze"]=0.0019721;
M[1]["tej"]=0.0018742;
M[1]["bardzo"]=0.0017802;
M[1]["azeby"]=0.0017435;
M[1]["Wokulskiego"]=0.0017312;
M[1]["byl"]=0.0017149;
M[1]["albo"]=0.0016863;
M[1]["pana"]=0.0016496;
M[1]["nim"]=0.0016169;
M[1]["tego"]=0.0015516;
M[1]["odparl"]=0.0015393;
M[1]["przez"]=0.0015393;
M[1]["u"]=0.0015067;
M[1]["wiec"]=0.0014985;
M[1]["rubli"]=0.0014699;
M[1]["rzekl"]=0.0014168;
M[1]["bo"]=0.0013760;
M[1]["chwili"]=0.0013760;
M[1]["tu"]=0.0013556;
M[1]["bylo"]=0.0013393;
M[1]["kiedy"]=0.0013352;
M[1]["znowu"]=0.0013229;
M[1]["przed"]=0.0013107;
M[1]["czlowiek"]=0.0013066;
M[1]["jezeli"]=0.0012903;
M[1]["ktora"]=0.0012903;
M[1]["mowil"]=0.0012698;
M[1]["dzis"]=0.0012658;
M[1]["tysiecy"]=0.0012576;
M[1]["Pan"]=0.0012535;
M[1]["przy"]=0.0012535;
M[1]["tam"]=0.0012454;
M[1]["niej"]=0.0012372;
M[1]["ich"]=0.0012127;
M[1]["To"]=0.0012086;
M[1]["jednak"]=0.0011841;
M[1]["Rzecki"]=0.0011637;
M[1]["byc"]=0.0011637;
M[1]["nic"]=0.0011637;
M[1]["te"]=0.0011433;
M[1]["Co"]=0.0011310;
M[1]["bedzie"]=0.0011269;
M[1]["niego"]=0.0011229;
M[1]["nas"]=0.0011147;
M[1]["zas"]=0.0011147;
M[1]["wszystko"]=0.0010984;
M[1]["Na"]=0.0010861;
M[1]["siebie"]=0.0010779;
M[1]["sa"]=0.0010412;
M[1]["mial"]=0.0010371;
M[1]["ani"]=0.0010289;
M[1]["pod"]=0.0010208;
M[2]["i"]=0.0381469;
M[2]["sie"]=0.0254748;
M[2]["w"]=0.0215003;
M[2]["nie"]=0.0178763;
M[2]["na"]=0.0160168;
M[2]["ze"]=0.0156782;
M[2]["z"]=0.0147989;
M[2]["do"]=0.0105274;
M[2]["to"]=0.0071173;
M[2]["a"]=0.0064044;
M[2]["o"]=0.0054835;
M[2]["jak"]=0.0052934;
M[2]["ja"]=0.0052518;
M[2]["mu"]=0.0050023;
M[2]["jej"]=0.0045686;
M[2]["jego"]=0.0044676;
M[2]["go"]=0.0044082;
M[2]["po"]=0.0042003;
M[2]["za"]=0.0040933;
M[2]["jest"]=0.0040814;
M[2]["ale"]=0.0039567;
M[2]["Winicjusz"]=0.0036299;
M[2]["od"]=0.0035289;
M[2]["by"]=0.0032794;
M[2]["tak"]=0.0032794;
M[2]["zas"]=0.0032556;
M[2]["co"]=0.0032259;
M[2]["rzekl"]=0.0031962;
M[2]["mnie"]=0.0030952;
M[2]["mi"]=0.0029824;
M[2]["tylko"]=0.0029051;
M[2]["ktory"]=0.0028814;
M[2]["jeszcze"]=0.0027625;
M[2]["ci"]=0.0026437;
M[2]["I"]=0.0026378;
M[2]["ich"]=0.0025843;
M[2]["juz"]=0.0025308;
M[2]["Petroniusz"]=0.0025190;
M[2]["Lecz"]=0.0024893;
M[2]["gdy"]=0.0024893;
M[2]["bylo"]=0.0024596;
M[2]["przez"]=0.0024299;
M[2]["dla"]=0.0023704;
M[2]["tym"]=0.0023645;
M[2]["byl"]=0.0022635;
M[2]["Nie"]=0.0022041;
M[2]["jednak"]=0.0021209;
M[2]["sobie"]=0.0020972;
M[2]["ktora"]=0.0019783;
M[2]["nim"]=0.0019665;
M[2]["A"]=0.0018892;
M[2]["moze"]=0.0018892;
M[2]["poczal"]=0.0018061;
M[2]["chwili"]=0.0017942;
M[2]["tego"]=0.0017942;
M[2]["przy"]=0.0017526;
M[2]["nad"]=0.0017466;
M[2]["wiec"]=0.0017407;
M[2]["jakby"]=0.0017169;
M[2]["nawet"]=0.0016991;
M[2]["Ligia"]=0.0016694;
M[2]["domu"]=0.0016694;
M[2]["lub"]=0.0016575;
M[2]["lecz"]=0.0016516;
M[2]["W"]=0.0015506;
M[2]["ktorych"]=0.0015506;
M[2]["on"]=0.0015328;
M[2]["teraz"]=0.0015328;
M[2]["Winicjusza"]=0.0015209;
M[2]["czym"]=0.0015209;
M[2]["cezara"]=0.0015149;
M[2]["przed"]=0.0015149;
M[2]["cie"]=0.0015031;
M[2]["ktore"]=0.0014912;
M[2]["niego"]=0.0014674;
M[2]["czy"]=0.0014199;
M[2]["Ale"]=0.0013842;
M[2]["Ligii"]=0.0013783;
M[2]["niej"]=0.0013724;
M[2]["sam"]=0.0013605;
M[2]["mogl"]=0.0013545;
M[2]["byc"]=0.0013486;
M[2]["bedzie"]=0.0013367;
M[2]["panie"]=0.0013248;
M[2]["oczy"]=0.0012892;
M[2]["tej"]=0.0012654;
M[2]["Na"]=0.0012535;
M[2]["pod"]=0.0012476;
M[2]["Po"]=0.0012179;
M[2]["cezar"]=0.0012179;
M[2]["albowiem"]=0.0012120;
M[2]["ku"]=0.0011941;
M[2]["mowil"]=0.0011941;
M[2]["jesli"]=0.0011466;
M[2]["ten"]=0.0011466;
M[2]["ty"]=0.0011288;
M[2]["bo"]=0.0011110;
M[2]["nia"]=0.0011110;
M[2]["Nero"]=0.0010931;
M[2]["ludzi"]=0.0010813;
M[2]["te"]=0.0010813;
然后最后运用得到的概率进行输入和判断即可,判断的过程就是下面这一段
if(dif[0]<=dif[1] && dif[0]<=dif[2])
printf("Mickiewicz\n");
else if(dif[1]<=dif[0] && dif[1]<=dif[2])
printf("Prus\n");
else
printf("Sienkiewicz\n");
最后就是整个的代码了!(来自 std)
还放代码是因为给定单词的拆分的分析没放,所以放 std 了。
Code
#include <bits/stdc++.h>
using namespace std;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
double Q[3][555];
map < string , double > M[3];
void makedata(){
fill(Q[0],Q[0]+555,0.0);
fill(Q[1],Q[1]+555,0.0);
fill(Q[2],Q[2]+555,0.0);
Q[0][' ']=0.15634;
Q[0][',']=0.02080;
Q[0]['.']=0.00655;
Q[0][';']=0.00333;
Q[0][':']=0.00267;
Q[0]['"']=0.00243;
Q[0]['!']=0.00239;
Q[0]['-']=0.00144;
Q[0]['?']=0.00099;
Q[0]['*']=0.00032;
Q[0][')']=0.00016;
Q[1][' ']=0.15888;
Q[1]['.']=0.02443;
Q[1][',']=0.01425;
Q[1]['-']=0.00767;
Q[1]['?']=0.00198;
Q[1]['!']=0.00160;
Q[1]['"']=0.00127;
Q[1][':']=0.00095;
Q[1][';']=0.00063;
Q[1][')']=0.00018;
Q[1]['0']=0.00003;
Q[1]['8']=0.00003;
Q[1]['\'']=0.00001;
Q[1]['5']=0.00001;
Q[1]['9']=0.00001;
Q[1]['6']=0.00001;
Q[1]['7']=0.00001;
Q[1]['4']=0.00001;
Q[2][' ']=0.15901;
Q[2][',']=0.01825;
Q[2]['.']=0.00963;
Q[2]['-']=0.00342;
Q[2]['!']=0.00126;
Q[2][':']=0.00107;
Q[2]['?']=0.00088;
Q[2]['"']=0.00075;
Q[2][';']=0.00020;
Q[2][')']=0.00002;
Q[2]['\'']=0.00000;
M[0]["w"]=0.0220758;
M[0]["sie"]=0.0219952;
M[0]["i"]=0.0207706;
M[0]["z"]=0.0181924;
M[0]["na"]=0.0169194;
M[0]["nie"]=0.0112957;
M[0]["I"]=0.0106189;
M[0]["do"]=0.0077185;
M[0]["ze"]=0.0073640;
M[0]["jak"]=0.0068161;
M[0]["to"]=0.0064133;
M[0]["A"]=0.0049630;
M[0]["po"]=0.0040284;
M[0]["za"]=0.0040284;
M[0]["o"]=0.0038189;
M[0]["juz"]=0.0034806;
M[0]["a"]=0.0032227;
M[0]["tak"]=0.0031744;
M[0]["co"]=0.0030616;
M[0]["od"]=0.0029327;
M[0]["W"]=0.0028844;
M[0]["ja"]=0.0026588;
M[0]["Na"]=0.0024654;
M[0]["Nie"]=0.0022881;
M[0]["byl"]=0.0022720;
M[0]["Z"]=0.0022398;
M[0]["Ze"]=0.0022237;
M[0]["jest"]=0.0021270;
M[0]["nim"]=0.0021109;
M[0]["mu"]=0.0020787;
M[0]["go"]=0.0020626;
M[0]["pan"]=0.0019981;
M[0]["Hrabia"]=0.0018531;
M[0]["Sedzia"]=0.0018370;
M[0]["rzekl"]=0.0018208;
M[0]["Ale"]=0.0017725;
M[0]["gdy"]=0.0017242;
M[0]["Bo"]=0.0017081;
M[0]["Jak"]=0.0017081;
M[0]["mnie"]=0.0016436;
M[0]["tylko"]=0.0016436;
M[0]["ich"]=0.0015953;
M[0]["Lecz"]=0.0015791;
M[0]["jako"]=0.0015469;
M[0]["pod"]=0.0015469;
M[0]["dla"]=0.0015147;
M[0]["tym"]=0.0014825;
M[0]["tam"]=0.0014180;
M[0]["Tadeusz"]=0.0013858;
M[0]["u"]=0.0013697;
M[0]["tu"]=0.0013536;
M[0]["nad"]=0.0013374;
M[0]["Wojski"]=0.0013213;
M[0]["bez"]=0.0013213;
M[0]["lecz"]=0.0013213;
M[0]["ten"]=0.0013213;
M[0]["To"]=0.0012891;
M[0]["jej"]=0.0012891;
M[0]["przez"]=0.0012569;
M[0]["przy"]=0.0012569;
M[0]["przed"]=0.0012408;
M[0]["jeszcze"]=0.0012246;
M[0]["on"]=0.0011924;
M[0]["Tak"]=0.0011763;
M[0]["bylo"]=0.0011763;
M[0]["ku"]=0.0011763;
M[0]["sam"]=0.0011763;
M[0]["Gdy"]=0.0011441;
M[0]["bo"]=0.0011280;
M[0]["ma"]=0.0011280;
M[0]["domu"]=0.0011118;
M[0]["Juz"]=0.0010957;
M[0]["mi"]=0.0010957;
M[0]["Ja"]=0.0010796;
M[0]["jego"]=0.0010796;
M[0]["mial"]=0.0010796;
M[0]["oczy"]=0.0010796;
M[0]["by"]=0.0010635;
M[0]["wszyscy"]=0.0010474;
M[0]["O"]=0.0010313;
M[0]["On"]=0.0010152;
M[0]["nas"]=0.0010152;
M[0]["te"]=0.0010152;
M[0]["czy"]=0.0009990;
M[0]["gdzie"]=0.0009990;
M[0]["Az"]=0.0009346;
M[0]["Gerwazy"]=0.0009185;
M[0]["tez"]=0.0009024;
M[0]["Co"]=0.0008863;
M[0]["Telimena"]=0.0008863;
M[0]["sobie"]=0.0008863;
M[0]["znowu"]=0.0008863;
M[0]["Czy"]=0.0008701;
M[0]["kto"]=0.0008701;
M[0]["az"]=0.0008540;
M[0]["rece"]=0.0008540;
M[0]["choc"]=0.0008379;
M[0]["glowy"]=0.0008379;
M[0]["szlachta"]=0.0008379;
M[0]["tej"]=0.0008379;
M[0]["we"]=0.0008379;
M[1]["sie"]=0.0276917;
M[1]["i"]=0.0266913;
M[1]["nie"]=0.0179453;
M[1]["w"]=0.0175207;
M[1]["na"]=0.0160956;
M[1]["ze"]=0.0153933;
M[1]["z"]=0.0147564;
M[1]["do"]=0.0122371;
M[1]["to"]=0.0089992;
M[1]["a"]=0.0079294;
M[1]["pan"]=0.0069290;
M[1]["Wokulski"]=0.0067453;
M[1]["o"]=0.0057817;
M[1]["za"]=0.0056306;
M[1]["co"]=0.0047242;
M[1]["ja"]=0.0046262;
M[1]["jest"]=0.0046262;
M[1]["jak"]=0.0046221;
M[1]["mu"]=0.0043404;
M[1]["ale"]=0.0043036;
M[1]["mnie"]=0.0041158;
M[1]["go"]=0.0039647;
M[1]["mi"]=0.0038749;
M[1]["pani"]=0.0038422;
M[1]["po"]=0.0037361;
M[1]["tak"]=0.0036585;
M[1]["od"]=0.0035931;
M[1]["juz"]=0.0034951;
M[1]["A"]=0.0032869;
M[1]["tylko"]=0.0032461;
M[1]["nawet"]=0.0032012;
M[1]["jej"]=0.0031807;
M[1]["Nie"]=0.0024335;
M[1]["W"]=0.0023805;
M[1]["Ale"]=0.0023355;
M[1]["tym"]=0.0023070;
M[1]["sobie"]=0.0022988;
M[1]["panna"]=0.0022947;
M[1]["ktory"]=0.0022743;
M[1]["jeszcze"]=0.0022580;
M[1]["jego"]=0.0022008;
M[1]["ma"]=0.0021151;
M[1]["panie"]=0.0020987;
M[1]["czy"]=0.0020620;
M[1]["I"]=0.0020252;
M[1]["dla"]=0.0020130;
M[1]["ten"]=0.0020130;
M[1]["on"]=0.0020089;
M[1]["Izabela"]=0.0019844;
M[1]["moze"]=0.0019721;
M[1]["tej"]=0.0018742;
M[1]["bardzo"]=0.0017802;
M[1]["azeby"]=0.0017435;
M[1]["Wokulskiego"]=0.0017312;
M[1]["byl"]=0.0017149;
M[1]["albo"]=0.0016863;
M[1]["pana"]=0.0016496;
M[1]["nim"]=0.0016169;
M[1]["tego"]=0.0015516;
M[1]["odparl"]=0.0015393;
M[1]["przez"]=0.0015393;
M[1]["u"]=0.0015067;
M[1]["wiec"]=0.0014985;
M[1]["rubli"]=0.0014699;
M[1]["rzekl"]=0.0014168;
M[1]["bo"]=0.0013760;
M[1]["chwili"]=0.0013760;
M[1]["tu"]=0.0013556;
M[1]["bylo"]=0.0013393;
M[1]["kiedy"]=0.0013352;
M[1]["znowu"]=0.0013229;
M[1]["przed"]=0.0013107;
M[1]["czlowiek"]=0.0013066;
M[1]["jezeli"]=0.0012903;
M[1]["ktora"]=0.0012903;
M[1]["mowil"]=0.0012698;
M[1]["dzis"]=0.0012658;
M[1]["tysiecy"]=0.0012576;
M[1]["Pan"]=0.0012535;
M[1]["przy"]=0.0012535;
M[1]["tam"]=0.0012454;
M[1]["niej"]=0.0012372;
M[1]["ich"]=0.0012127;
M[1]["To"]=0.0012086;
M[1]["jednak"]=0.0011841;
M[1]["Rzecki"]=0.0011637;
M[1]["byc"]=0.0011637;
M[1]["nic"]=0.0011637;
M[1]["te"]=0.0011433;
M[1]["Co"]=0.0011310;
M[1]["bedzie"]=0.0011269;
M[1]["niego"]=0.0011229;
M[1]["nas"]=0.0011147;
M[1]["zas"]=0.0011147;
M[1]["wszystko"]=0.0010984;
M[1]["Na"]=0.0010861;
M[1]["siebie"]=0.0010779;
M[1]["sa"]=0.0010412;
M[1]["mial"]=0.0010371;
M[1]["ani"]=0.0010289;
M[1]["pod"]=0.0010208;
M[2]["i"]=0.0381469;
M[2]["sie"]=0.0254748;
M[2]["w"]=0.0215003;
M[2]["nie"]=0.0178763;
M[2]["na"]=0.0160168;
M[2]["ze"]=0.0156782;
M[2]["z"]=0.0147989;
M[2]["do"]=0.0105274;
M[2]["to"]=0.0071173;
M[2]["a"]=0.0064044;
M[2]["o"]=0.0054835;
M[2]["jak"]=0.0052934;
M[2]["ja"]=0.0052518;
M[2]["mu"]=0.0050023;
M[2]["jej"]=0.0045686;
M[2]["jego"]=0.0044676;
M[2]["go"]=0.0044082;
M[2]["po"]=0.0042003;
M[2]["za"]=0.0040933;
M[2]["jest"]=0.0040814;
M[2]["ale"]=0.0039567;
M[2]["Winicjusz"]=0.0036299;
M[2]["od"]=0.0035289;
M[2]["by"]=0.0032794;
M[2]["tak"]=0.0032794;
M[2]["zas"]=0.0032556;
M[2]["co"]=0.0032259;
M[2]["rzekl"]=0.0031962;
M[2]["mnie"]=0.0030952;
M[2]["mi"]=0.0029824;
M[2]["tylko"]=0.0029051;
M[2]["ktory"]=0.0028814;
M[2]["jeszcze"]=0.0027625;
M[2]["ci"]=0.0026437;
M[2]["I"]=0.0026378;
M[2]["ich"]=0.0025843;
M[2]["juz"]=0.0025308;
M[2]["Petroniusz"]=0.0025190;
M[2]["Lecz"]=0.0024893;
M[2]["gdy"]=0.0024893;
M[2]["bylo"]=0.0024596;
M[2]["przez"]=0.0024299;
M[2]["dla"]=0.0023704;
M[2]["tym"]=0.0023645;
M[2]["byl"]=0.0022635;
M[2]["Nie"]=0.0022041;
M[2]["jednak"]=0.0021209;
M[2]["sobie"]=0.0020972;
M[2]["ktora"]=0.0019783;
M[2]["nim"]=0.0019665;
M[2]["A"]=0.0018892;
M[2]["moze"]=0.0018892;
M[2]["poczal"]=0.0018061;
M[2]["chwili"]=0.0017942;
M[2]["tego"]=0.0017942;
M[2]["przy"]=0.0017526;
M[2]["nad"]=0.0017466;
M[2]["wiec"]=0.0017407;
M[2]["jakby"]=0.0017169;
M[2]["nawet"]=0.0016991;
M[2]["Ligia"]=0.0016694;
M[2]["domu"]=0.0016694;
M[2]["lub"]=0.0016575;
M[2]["lecz"]=0.0016516;
M[2]["W"]=0.0015506;
M[2]["ktorych"]=0.0015506;
M[2]["on"]=0.0015328;
M[2]["teraz"]=0.0015328;
M[2]["Winicjusza"]=0.0015209;
M[2]["czym"]=0.0015209;
M[2]["cezara"]=0.0015149;
M[2]["przed"]=0.0015149;
M[2]["cie"]=0.0015031;
M[2]["ktore"]=0.0014912;
M[2]["niego"]=0.0014674;
M[2]["czy"]=0.0014199;
M[2]["Ale"]=0.0013842;
M[2]["Ligii"]=0.0013783;
M[2]["niej"]=0.0013724;
M[2]["sam"]=0.0013605;
M[2]["mogl"]=0.0013545;
M[2]["byc"]=0.0013486;
M[2]["bedzie"]=0.0013367;
M[2]["panie"]=0.0013248;
M[2]["oczy"]=0.0012892;
M[2]["tej"]=0.0012654;
M[2]["Na"]=0.0012535;
M[2]["pod"]=0.0012476;
M[2]["Po"]=0.0012179;
M[2]["cezar"]=0.0012179;
M[2]["albowiem"]=0.0012120;
M[2]["ku"]=0.0011941;
M[2]["mowil"]=0.0011941;
M[2]["jesli"]=0.0011466;
M[2]["ten"]=0.0011466;
M[2]["ty"]=0.0011288;
M[2]["bo"]=0.0011110;
M[2]["nia"]=0.0011110;
M[2]["Nero"]=0.0010931;
M[2]["ludzi"]=0.0010813;
M[2]["te"]=0.0010813;
}
char s[2000005];
double cur[555];
map < string , double > curmp;
int tot;
vector < string > getstr(char *s,int len){
int i,j,k;
vector < string > ret;tot=0;
for(i=0;i<len;){
for(j=i;j<len;++j){
if(!(s[j]>='a' && s[j]<='z') && !(s[j]>='A' && s[j]<='Z'))
break;
}
if(j>i+1){
ret.emplace_back(s+i,s+j);
// cout<<ret.back()<<endl;
++tot;
}
i=j+1;
}
return ret;
}
int main(){
int i,j,k,t;
makedata();
scanf("%d",&t);getchar();
while(t--){
cin.getline(s,(int)2e6);
int len=strlen(s);
fill(cur,cur+555,0.0);
curmp.clear();
int fc2=0;
for(i=0;i<len;++i){
if(s[i]>='a' && s[i]<='z') continue;
if(s[i]>='A' && s[i]<='Z') continue;
if(s[i]=='\n') continue;
cur[s[i]]+=1/(double)len;
++fc2;
}
vector < string > str=getstr(s,len);
for(i=0;i<(int)str.size();++i){
curmp[str[i]]+=1/(double)tot;
}
double dif[3]={0,0,0};
double ratio=(double)fc2*(tot>15?3.0:0.1)/(double)tot;
for(i=0;i<3;++i){
for(j=0;j<555;++j){
if(j==(int)' ') continue;
dif[i]+=fabs(Q[i][j]-cur[j])*ratio;
}
}
map < string , double >::iterator it;
for(it=curmp.begin();it!=curmp.end();++it){
for(i=0;i<3;++i){
dif[i]+=fabs(M[i][it->FS]-it->SC);
}
}
if(dif[0]<=dif[1] && dif[0]<=dif[2])
printf("Mickiewicz\n");
else if(dif[1]<=dif[0] && dif[1]<=dif[2])
printf("Prus\n");
else
printf("Sienkiewicz\n");
}
return 0;
}
// If encounter problem while debugging, try switching compiler to TDM-GCC-64.
然后我们得到了 3397 pts 的好成绩!
其实不是,3397 pts 是 spj 坏掉之前的分数(
这个代码可以获得 52 pts 的成绩,因为这个代码还是有运气的成分和概率的成分。
谁知道打表比正解的数据分析得的分还要高 /lb
By Shuchong
2020.8.7
年轻人耗子尾汁(doge).
这都是什么神仙题啊/fad
书虫!!!!!!!!!!!!!!