Submission #42739880


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=atcoder::modint998244353;
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int main(){
	int n,w;
	cin >> n >> w;
	string t,p;
	cin >> t >> p;
	rep(i,0,w-1)t+='.';
	rep(i,0,n)t+=t[i];
	if(w==n)t.pop_back();
	rep(i,0,w-n-1)t+='.';
	reverse(p.begin(),p.end());
	
	unordered_map<char,int>num;
	num['_']=0;
	num['.']=1;
	rep(i,0,26)num['a'+i]=i+2;
	rep(i,0,26)num['A'+i]=i+2+26;
	
	vector<mint>t2(t.size()),t1(t.size()),p2(p.size()),p1(p.size());
	mint p3=0;
	rep(i,0,t.size()){
		int x=num[t[i]];
		t2[i]=x*x;
		t1[i]=x;
	}
	rep(i,0,p.size()){
		int x=num[p[i]];
		p3+=x*x*(p[i]!='_');
		p2[i]=x*(p[i]!='_');
		p1[i]=(p[i]!='_');
	}
	
	auto x1=convolution(t2,p1);
	auto x2=convolution(t1,p2);
	
	int ans=0;
	rep(i,w-1,(w-1)+(n+w-1))if(x1[i]-2*x2[i]+p3==0)ans++;
	
	cout << ans << endl;
}

Submission Info

Submission Time
Task Ex - Marquee
User kyopro_friends
Language C++ (GCC 9.2.1)
Score 600
Code Size 947 Byte
Status AC
Exec Time 291 ms
Memory 43008 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:7:34: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define rep(i,l,r)for(int i=(l);i<(r);i++)
      |                                  ^
./Main.cpp:28:2: note: in expansion of macro ‘rep’
   28 |  rep(i,0,t.size()){
      |  ^~~
./Main.cpp:7:34: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define rep(i,l,r)for(int i=(l);i<(r);i++)
      |                                  ^
./Main.cpp:33:2: note: in expansion of macro ‘rep’
   33 |  rep(i,0,p.size()){
      |  ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 61
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt, random_45.txt, random_46.txt, random_47.txt, random_48.txt, random_49.txt, random_50.txt, random_51.txt, random_52.txt, random_53.txt, random_54.txt, random_55.txt, random_56.txt, random_57.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
random_01.txt AC 291 ms 42352 KiB
random_02.txt AC 79 ms 14228 KiB
random_03.txt AC 147 ms 24856 KiB
random_04.txt AC 141 ms 23148 KiB
random_05.txt AC 157 ms 25924 KiB
random_06.txt AC 144 ms 23124 KiB
random_07.txt AC 150 ms 25452 KiB
random_08.txt AC 77 ms 13288 KiB
random_09.txt AC 280 ms 42272 KiB
random_10.txt AC 149 ms 24068 KiB
random_11.txt AC 151 ms 25892 KiB
random_12.txt AC 77 ms 14096 KiB
random_13.txt AC 277 ms 41576 KiB
random_14.txt AC 75 ms 13244 KiB
random_15.txt AC 153 ms 25888 KiB
random_16.txt AC 150 ms 24796 KiB
random_17.txt AC 279 ms 42316 KiB
random_18.txt AC 146 ms 24232 KiB
random_19.txt AC 150 ms 25372 KiB
random_20.txt AC 42 ms 8424 KiB
random_21.txt AC 151 ms 25404 KiB
random_22.txt AC 148 ms 24436 KiB
random_23.txt AC 151 ms 25720 KiB
random_24.txt AC 275 ms 41248 KiB
random_25.txt AC 148 ms 24744 KiB
random_26.txt AC 77 ms 13712 KiB
random_27.txt AC 151 ms 25156 KiB
random_28.txt AC 150 ms 24688 KiB
random_29.txt AC 148 ms 24976 KiB
random_30.txt AC 140 ms 23424 KiB
random_31.txt AC 280 ms 42456 KiB
random_32.txt AC 16 ms 4600 KiB
random_33.txt AC 281 ms 42544 KiB
random_34.txt AC 149 ms 24780 KiB
random_35.txt AC 276 ms 41392 KiB
random_36.txt AC 43 ms 8416 KiB
random_37.txt AC 152 ms 24900 KiB
random_38.txt AC 143 ms 24640 KiB
random_39.txt AC 151 ms 25692 KiB
random_40.txt AC 144 ms 22696 KiB
random_41.txt AC 151 ms 25344 KiB
random_42.txt AC 146 ms 23972 KiB
random_43.txt AC 281 ms 42992 KiB
random_44.txt AC 74 ms 13000 KiB
random_45.txt AC 279 ms 43004 KiB
random_46.txt AC 142 ms 23332 KiB
random_47.txt AC 280 ms 43008 KiB
random_48.txt AC 143 ms 23168 KiB
random_49.txt AC 4 ms 3648 KiB
random_50.txt AC 2 ms 3648 KiB
random_51.txt AC 2 ms 3652 KiB
random_52.txt AC 283 ms 42960 KiB
random_53.txt AC 284 ms 42992 KiB
random_54.txt AC 274 ms 41188 KiB
random_55.txt AC 41 ms 8480 KiB
random_56.txt AC 74 ms 13000 KiB
random_57.txt AC 137 ms 22328 KiB
sample_01.txt AC 2 ms 3588 KiB
sample_02.txt AC 3 ms 3532 KiB
sample_03.txt AC 2 ms 3456 KiB
sample_04.txt AC 2 ms 3500 KiB