Language: C++

#include <bits/stdc++.h>
using namespace std;
 
const unsigned long long M=998244353;
const unsigned long long X=99469;
unsigned long long R;
const int W=1500;
 
 
unsigned long long ModPow(unsigned long long x, unsigned long long n, unsigned long long mod) {
        unsigned long long ret = 1;
        for (; n > 0; n /= 2, x = (x * x) % mod)
            if ((n & 1) == 1) ret = (ret * x) % mod;
        return ret;
    }
 
unsigned long long has=0,vec=1;
 
int n;
string s;
unordered_map<unsigned long long,int> B[550];
long long ans;
inline void calc(char c, unsigned long long &u,unsigned long long &p){
	if(c=='+')u=(u+p)%M;
	else if(c=='-')u=(u+M-p)%M;
	else if(c=='>')p=(p*X)%M;
	else p=(p*R)%M;
}
int main(){
	R=ModPow(X,M-2,M);
	cin>>n>>s;
    //n=250000;
    //s=string(n,'+');
	for(int i=0;i<n;i++)calc(s[i],has,vec);
	for(int i=0;i<n;i++){
		if(i%W==0)continue;
		unsigned long long h=0,x=1;
		for(int j=i;j<n;j++){
			if(j%W==0)break;
			calc(s[j],h,x);
			if(h==has)ans++;
		}
		unsigned long long nh = (has+M-h)%M;
		nh = nh * ModPow(x,M-2,M)%M;
		B[i/W+1][nh]++;
	}
	for(int i=0;i<n;i+=W){
		unsigned long long h=0,x=1;
		for(int j=i;j<n;j++){
			calc(s[j],h,x);
			if(h==has)ans++;
			auto it = B[i/W].find(h);
			if(it!=B[i/W].end())ans+=it->second;
		}
	}
	
	cout<<ans;
 
 
}
#include <bits/stdc++.h>
using namespace std;

const unsigned long long M=998244353;
const unsigned long long X=99497;
unsigned long long R;
const int W=1500;


unsigned long long ModPow(unsigned long long x, unsigned long long n, unsigned long long mod) {
        unsigned long long ret = 1;
        for (; n > 0; n /= 2, x = (x * x) % mod)
            if ((n & 1) == 1) ret = (ret * x) % mod;
        return ret;
    }

unsigned long long has=0,vec=1;

int n;
string s;
unordered_map<unsigned long long,int> B[550];
long long ans;
inline void calc(char c, unsigned long long &u,unsigned long long &p){
	if(c=='+')u=(u+p)%M;
	else if(c=='-')u=(u+M-p)%M;
	else if(c=='>')p=(p*X)%M;
	else p=(p*R)%M;
}
int main(){
	R=ModPow(X,M-2,M);
	cin>>n>>s;
    //n=250000;
    //s=string(n,'+');
	for(int i=0;i<n;i++)calc(s[i],has,vec);
	for(int i=0;i<n;i++){
		if(i%W==0)continue;
		unsigned long long h=0,x=1;
		for(int j=i;j<n;j++){
			if(j%W==0)break;
			calc(s[j],h,x);
			if(h==has)ans++;
		}
		unsigned long long nh = (has+M-h)%M;
		nh = nh * ModPow(x,M-2,M)%M;
		B[i/W+1][nh]++;
	}
	for(int i=0;i<n;i+=W){
		unsigned long long h=0,x=1;
		for(int j=i;j<n;j++){
			calc(s[j],h,x);
			if(h==has)ans++;
			auto it = B[i/W].find(h);
			if(it!=B[i/W].end())ans+=it->second;
		}
	}
	
	cout<<ans;


}
提出情報
提出日時

Compiler output:
a.cc:64:26: error: redefinition of 'const long long unsigned int M'
   64 | const unsigned long long M=998244353;
      |                          ^
a.cc:4:26: note: 'const long long unsigned int M' previously defined here
    4 | const unsigned long long M=998244353;
      |                          ^
a.cc:65:26: error: redefinition of 'const long long unsigned int X'
   65 | const unsigned long long X=99497;
      |                          ^
a.cc:5:26: note: 'const long long unsigned int X' previously defined here
    5 | const unsigned long long X=99469;
      |                          ^
a.cc:66:20: error: redefinition of 'long long unsigned int R'
   66 | unsigned long long R;
      |                    ^
a.cc:6:20: note: 'long long unsigned int R' previously declared here
    6 | unsigned long long R;
      |                    ^
a.cc:67:11: error: redefinition of 'const int W'
   67 | const int W=1500;
      |           ^
a.cc:7:11: note: 'const int W' previously defined here
    7 | const int W=1500;
      |           ^
a.cc:70:20: error: redefinition of 'long long unsigned int ModPow(long long unsigned int, long long unsigned int, long long unsigned int)'
   70 | unsigned long long ModPow(unsigned long long x, unsigned long long n, unsigned long long mod) {
      |                    ^~~~~~
a.cc:10:20: note: 'long long unsigned int ModPow(long long unsigned int, long long unsigned int, long long unsigned int)' previously defined here
   10 | unsigned long long ModPow(unsigned long long x, unsigned long long n, unsigned long long mod) {
      |                    ^~~~~~
a.cc:77:20: error: redefinition of 'long long unsigned int has'
   77 | unsigned long long has=0,vec=1;
      |                    ^~~
a.cc:17:20: note: 'long long unsigned int has' previously defined here
   17 | unsigned long long has=0,vec=1;
      |                    ^~~
a.cc:77:26: error: redefinition of 'long long unsigned int vec'
   77 | unsigned long long has=0,vec=1;
      |                          ^~~
a.cc:17:26: note: 'long long unsigned int vec' previously defined here
   17 | unsigned long long has=0,vec=1;
      |                          ^~~
a.cc:79:5: error: redefinition of 'int n'
   79 | int n;
      |     ^
a.cc:19:5: note: 'int n' previously declared here
   19 | int n;
      |     ^
a.cc:80:8: error: redefinition of 'std::string s'
   80 | string s;
      |        ^
a.cc:20:8: note: 'std::string s' previously declared here
   20 | string s;
      |        ^
a.cc:81:39: error: redefinition of 'std::unordered_map<long long unsigned int, int> B [550]'
   81 | unordered_map<unsigned long long,int> B[550];
      |                                       ^
a.cc:21:39: note: 'std::unordered_map<long long unsigned int, int> B [550]' previously declared here
   21 | unordered_map<unsigned long long,int> B[550];
      |                                       ^
a.cc:82:11: error: redefinition of 'long long int ans'
   82 | long long ans;
      |           ^~~
a.cc:22:11: note: 'long long int ans' previously declared here
   22 | long long ans;
      |           ^~~
a.cc:83:13: error: redefinition of 'void calc(char, long long unsigned int&, long long unsigned int&)'
   83 | inline void calc(char c, unsigned long long &u,unsigned long long &p){
      |             ^~~~
a.cc:23:13: note: 'void calc(char, long long unsigned int&, long long unsigned int&)' previously defined here
   23 | inline void calc(char c, unsigned long long &u,unsigned long long &p){
      |             ^~~~
a.cc:89:5: error: redefinition of 'int main()'
   89 | int main(){
      |     ^~~~
a.cc:29:5: note: 'int main()' previously defined here
   29 | int main(){
      |     ^~~~
a.cc:121:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
  121 | 提出情報
      | ^~~~~~~~