QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#331579 | #8252. Tip of Your Tongue | Kevin5307# | AC ✓ | 1723ms | 332384kb | C++23 | 1.5kb | 2024-02-18 15:27:51 | 2024-02-18 15:27:52 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
mt19937_64 rnd(time(0));
const ll mod=998244353,base=rnd()%400+1000;
map<ll,int> M1[1001000],M2[1001000];
map<pair<ll,ll>,int> M3[1001000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
ll H1=0,H2=0;
for(int j=0;j<sz(s);j++)
{
H1=(H1*base+s[j])%mod;
H2=(H2*base+s[sz(s)-j-1])%mod;
M1[j+1][H1]++;
M2[j+1][H2]++;
M3[j+1][mp(H1,H2)]++;
}
}
while(q--)
{
string s;
cin>>s;
string A,B;
cin>>A>>B;
ll H1=0,H2=0;
for(auto ch:A)
H1=(H1*base+ch)%mod;
rev(B);
for(auto ch:B)
H2=(H2*base+ch)%mod;
if(s=="AND")
cout<<M3[sz(A)][mp(H1,H2)]<<endl;
else if(s=="OR")
cout<<M1[sz(A)][H1]+M2[sz(A)][H2]-M3[sz(A)][mp(H1,H2)]<<endl;
else
cout<<M1[sz(A)][H1]+M2[sz(A)][H2]-M3[sz(A)][mp(H1,H2)]*2<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 20ms
memory: 144640kb
input:
4 4 cat catcat octal occidental AND cat cat OR oc at AND ca at XOR oc al
output:
2 4 2 0
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 23ms
memory: 144456kb
input:
26 36 a b c d e f g h i j k l m n o p q r s t u v w x y z AND b b AND d d XOR tk ce AND w w AND z z XOR t t OR a a OR s s AND p p AND v v AND pp kh XOR j j AND n n OR f f XOR vo mj OR m m XOR q q XOR r r AND i i OR l l OR jb cg XOR x x XOR nf ov OR e e XOR h h XOR u u XOR c c OR y y XOR nc ln AND o ...
output:
1 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 1
result:
ok 36 lines
Test #3:
score: 0
Accepted
time: 48ms
memory: 177336kb
input:
18 18 a ab abba abbabaab abbabaabbaababba abbabaabbaababbabaababbaabbabaab abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababba abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaab abbabaabbaababbabaababbaabbabaa...
output:
18 17 8 8 14 7 6 11 10 5 4 3 3 2 2 0 1 0
result:
ok 18 lines
Test #4:
score: 0
Accepted
time: 128ms
memory: 332384kb
input:
1 1 ocyzfhhambhirbkeodnshorawhzsqakgywcadicyacxleobjmjrbgqrdqqvqecccxuahrkwnimglrcmiaujynldydopyasdbefpxmagfquhzrtfnuikojwpjocjwrogxhrquqruqqsunsjotsgeetddviaoswcavdswftyheurrclunactnwqhnqzrxjlsipyxxmmeiwxawqzvhtcmmadyvfzrhinphlibltwartaczraqkaaljefkksbawqmnsbquqxpbneshiuypfafihqtehavpdsoauwyvsqblxo...
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 24ms
memory: 145272kb
input:
1 1 a OR zxuxomuitrpatgdidwnuxfrwultbimmesgzkgcdsvjzmanhyebwdzowthmiqlsagxoqvyciyslmoxvceppnkjuvzhszgcdnpmdqxhbinbknbbzfcnhizysyeaemkpeandwqutpmnxytmnkzfghmptiqnppuwndlxlhpimvmsaytdycezpodqcbddybswutmimtpgzhmijvpphelairwewqshektuldufwxuzirjkpemoafnpopqfgxefcxuzgbbhehfpbmkdqbxsdejspcydluchncbhbfghoys...
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 411ms
memory: 199120kb
input:
250 50000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1 250 249 1 1 1 1 250 250 1 1 250 249 1 1 249 250 250 1 250 250 1 249 1 1 249 1 1 1 250 249 250 250 250 250 1 250 249 249 249 1 250 1 250 249 249 250 249 250 250 1 250 250 250 250 250 1 1 249 249 250 1 1 250 1 250 249 250 1 249 1 249 1 249 1 1 1 250 250 249 249 250 250 1 250 249 250 1 1 250 1 250 25...
result:
ok 50000 lines
Test #7:
score: 0
Accepted
time: 95ms
memory: 204880kb
input:
10 10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
10 10 0 10 10 10 10 0 0 10
result:
ok 10 lines
Test #8:
score: 0
Accepted
time: 356ms
memory: 184688kb
input:
10000 40000 lhheuleivzyldlchherj phgmehaliwwulthedmop ifszbvkgywuyemcxbvns wycojxbttxudiiclvgvk camfcfwvxlvyoyfyqsci zqkxtcfhovfemzizxhev ugbsvnxratulswilmekh cvveyzynvzgnfukgorio lsstnqurowhzvvzmvhwh crhuqauvnvwdeyqlxchi xvbybzkvzkjntwtdiglt ylgvjsugwaicedszzhlv jyswsdydzgicxheoqjfh jnbmcjgbyfmxyae...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 40000 lines
Test #9:
score: 0
Accepted
time: 1723ms
memory: 280204kb
input:
40000 10000 lynhbrgdcbqmazwibcti xxbyaqngttjaadowpoxd jyxvinberwqbykawbyvf vayqjzfyjlvzsuwwrsvs lukgakfkiiaxuedhtzpx uwhoadeqqzhkwggfebkj uyfreqcgwgtqvqlwitzf zajebujpbhufhvyowsbh sbnvcyswptsbbdvdxsxl oozymjrfnjogbxlbptbw vlxvuhfueomwhmjcddlc szffcnpiwpgrymdqimnp cesclsyvliesdrhoulim ceryoczqhltomnm...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 10000 lines
Test #10:
score: 0
Accepted
time: 1007ms
memory: 232520kb
input:
25000 25000 vdyrdfobpnmzkafujwav sejhjjarcfatdrxcdhxg tgvgnooftnykcynfbyxs xtzqsasggmfouxwbsnhz npwdngyaxjblnlqvgiqu ivcevcmhsezxcqyhihvt ilrztetzikmehuztbghe vosgdubogglelqdgjsyf gagqyoscjfirtpsdpcjy wdrhtcvbelqkxxiymjif iukqdbdggkpjftahbsuq huvznzywxqpmpfnrjgkc ieezfelxxquvridxswbl vhtrgplvqgewjhk...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 25000 lines
Test #11:
score: 0
Accepted
time: 898ms
memory: 225272kb
input:
50000 50000 fhbzhhsbzj iplzfbimxp plobcikqkd amxzydjuwi xiublxnnoi cpnwnulhjz cpspkovuot dvkiqopibs deehvpeijn cueklrdhay ubcoawbhvd irzkcpnyhv yehoeolcbq shxsfaekgn ynqdlcblvc avexwjuolf oabfylgpjm xkkqgisphg jiokzejjof ryobskxxtu rotajeixrg ctvimviwgz smbimudyle olnerzqovj woslasgtbg pewowwuuth th...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 50000 lines
Test #12:
score: 0
Accepted
time: 274ms
memory: 294472kb
input:
20 20 gddaatgysreztfnjttlpsfhskbxjqltiokdxifltzipusrztchtejvziswzynfyytotyefjuseowxnakvzvzecyfxstsbtegvmtzjsdaixnnjvoyrqfmvnqcgiqznzzyosolumqhzuhknstpsindhxfctphufyebubprvlxoqmtfsbcnehyjewncdmiyxxrotihfxvdkinwtbtfqyncrypmbrbevsvofswrfvcuzcpwdaxsxjqgluuvvsteaobdlnlwboswqmvbexhpxzmktadrtwvcsdpfyluwhht...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 20 lines
Test #13:
score: 0
Accepted
time: 161ms
memory: 238228kb
input:
20 20 vieddzryrbrgvezcrdvtfujyllhusrcemmxlarpmwccaeuvjnxecjxyxhhilaiyqtisyxxtfjnlzvepxiivavycywkkxdrmifgxggcupbbkvlymnrrvfaauoxieymchvdyravgowdvaoqjnbojfpgmtieydackvuruzhnmcblxlmiauyrpmbntnejwprfoeylbpzrpnjoqxpafdkfrnhfcjtbzpekpxfnwvjkpnvdlfbvrblsysybxpeonxwaqaiuqswbfialryoxezgoijbktvrisrrgrndkmtibl...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 20 lines
Test #14:
score: 0
Accepted
time: 142ms
memory: 238404kb
input:
10 10 fxbapnhzxqgypinkcwvcdffncpofscfumrhdywwsndelaxgwwintmtrbwbfkmycuuofnpkxusaxushqptczpkvjzutdgjbjubkvwopzvduvinmixbozzyuwnozuwemctztrcyqdwqejqbnvrsuhoherqgjdxctzfrdzysinwauupiealofgezefjzubjycpxswstyqcohmllwtfmrdtqakfgopirtyjlwniezmllpfcwloczdfgtwkxumffysdtpiclykobzoqqzprsjqjjfkcuaeokdxhhqgnxjpb...
output:
0 0 0 0 0 0 0 0 0 0
result:
ok 10 lines
Test #15:
score: 0
Accepted
time: 563ms
memory: 201128kb
input:
20000 15000 ycpcujwskbndpkstgaznlbryxji ycpcujwskbdseynvaaznlbryxji ycpcujwskbygsrainaznlbryxji ycpcujwskbnatcrctaznlbryxji ycpcujwskbkaxnsymaznlbryxji ycpcujwskbtpqpibsaznlbryxji ycpcujwskbhmudkxraznlbryxji ycpcujwskbueqmfflaznlbryxji ycpcujwskbfkeudapaznlbryxji ycpcujwskbjxnhhhsaznlbryxji ycpcujws...
output:
20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 ...
result:
ok 15000 lines
Test #16:
score: 0
Accepted
time: 28ms
memory: 145752kb
input:
10 2700 jmldwyxnouejzaqmujxahyissokibdqbgvqzauolmrjbzuibrkncaxfeepypxavmwqfntjzqszisvunypogzuiczxiaqkjlyzhmzirbnrsibwgyiqbvdqfccztiepuihkdqutzoctwnxfgixmawyyldzxrrtclpujhywsyidnetozusfvsfyrhfqfhufvlcwfwovdrlkczeinjygyjlijrygjplsssqhobmxdrgotnmwwwekgompkmfwjmvwgcsfrmmmlybrwcgnbsbxwpthpuwynlefetsygzln...
output:
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...
result:
ok 2700 lines
Test #17:
score: 0
Accepted
time: 22ms
memory: 145796kb
input:
10 2700 otckkjfmnhodtkatewfpeyxqurahqazyormsrsxhdioocfgslbxyzcnbiyvsgfxpfqcxkifjnzfuvhpytvyzqhnspltgahsczsnhdwbgwtfwjdhyisufyqupenclrlxwebpipopfmbpdjwelmiiocjddgyihlomaetukpbxxqpvjvqkfhupzhwdwdyshekxagurryjzaealcvqsomigcihlxtlgbiyutuqskwoofnqofgzkkgoncmkhjgijtlxfjewsampxorudxhlctcfspudtkrhnyexcyeoli...
output:
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...
result:
ok 2700 lines