Submission #00150


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
#define F first
#define S second
#define MP make_pair
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>PP;
typedef long long int ll;
int main(){
ll n,m;
cin>>n>>m;
map<string,int>str,bk,nat;
for(int i=0;i<n;i++){
string st;
cin>>st;
nat[st]++;
string p,q;
for(int i=0;i<st.size();i++){
p+=st[i];
str[p]++;
}
for(int i=st.size()-1;i>=0;i--){
q.insert(q.begin(),st[i]);
bk[q]++;
}
}
for(int i=0;i<m;i++){
string tg,dp;
cin>>tg;
int flontfg=0,backfg=0,quefg=-1;
for(int j=0;j<tg.size();j++){
if(tg[j]=='*'){
if(j==0){
flontfg=1;
}else{
backfg=1;
}
}else{
dp+=tg[j];
}
if(tg[j]=='?'){
quefg=j;
}
}
if(quefg==-1){
if(flontfg==0&&backfg==0){
cout<<nat[dp]<<endl;
}else if(flontfg==1){
cout<<bk[dp]<<endl;
}else if(backfg==1){
cout<<str[dp]<<endl;
}
}else{
if(flontfg==1){
quefg--;
}
int ans=0;
for(int l=0;l<26;l++){
dp[quefg]='a'+l;
if(flontfg==0&&backfg==0){
ans+=nat[dp];
}else if(flontfg==1){
ans+=bk[dp];
}else if(backfg==1){
ans+=str[dp];
}
}
cout<<ans<<endl;
}
}
return(0);
}

ステータス

項目 データ
問題 0008 - 石版
ユーザー名 kuriwonder
投稿日時 2019-09-10 17:29:28
言語 C++14
状態 Accepted
得点 15
ソースコード長 1346 Byte
最大実行時間 2108 ms
最大メモリ使用量 154948 KB

セット

セット 得点 Cases
1 ALL 15 / 15 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00_sample_00.in AC 27 ms 476 KB
1
01_rand_00.in AC 17 ms 440 KB
1
01_rand_01.in AC 21 ms 528 KB
1
01_rand_02.in AC 29 ms 480 KB
1
01_rand_03.in AC 25 ms 532 KB
1
01_rand_04.in AC 18 ms 636 KB
1
01_rand_05.in AC 23 ms 640 KB
1
01_rand_06.in AC 23 ms 636 KB
1
01_rand_07.in AC 22 ms 740 KB
1
01_small_00.in AC 17 ms 512 KB
1
02_large_00.in AC 129 ms 11732 KB
1
02_large_01.in AC 181 ms 17292 KB
1
02_large_02.in AC 1402 ms 80996 KB
1
02_large_03.in AC 2108 ms 154948 KB
1
03_critical_00.in AC 988 ms 93164 KB
1
03_critical_01.in AC 1010 ms 97364 KB
1
77_test_00.in AC 25 ms 2040 KB
1
77_test_01.in AC 25 ms 1960 KB
1
77_test_02.in AC 20 ms 1924 KB
1
77_test_03.in AC 24 ms 1944 KB
1
77_test_04.in AC 22 ms 1912 KB
1
77_test_05.in AC 22 ms 1980 KB
1
77_test_06.in AC 26 ms 1840 KB
1
77_test_07.in AC 22 ms 1676 KB
1
77_test_08.in AC 27 ms 1924 KB
1
77_test_09.in AC 25 ms 2044 KB
1
77_test_10.in AC 29 ms 1860 KB
1
77_test_11.in AC 26 ms 1836 KB
1
77_test_12.in AC 26 ms 1892 KB
1
77_test_13.in AC 24 ms 1760 KB
1
77_test_14.in AC 35 ms 1712 KB
1
77_test_15.in AC 24 ms 1596 KB
1
1000_test_00.in AC 35 ms 1928 KB
1
1000_test_01.in AC 28 ms 2480 KB
1
1000_test_02.in AC 33 ms 3024 KB
1
1000_test_03.in AC 39 ms 3204 KB
1
1000_test_04.in AC 32 ms 3308 KB
1
1000_test_05.in AC 39 ms 3184 KB
1
1000_test_06.in AC 38 ms 3336 KB
1
1000_test_07.in AC 37 ms 3740 KB
1
1000_test_08.in AC 37 ms 3876 KB
1
1000_test_09.in AC 41 ms 4224 KB
1
1000_test_10.in AC 39 ms 4632 KB
1