# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
165185 | theStaticMind | Lozinke (COCI17_lozinke) | C++14 | 586 ms | 19448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int n;
cin>>n;
vector<string>arr(n);
vector<int>H[n],h[n],Hh[n];
map<int,int>data;
for(int i=0;i<n;i++){
string s;
set<int> S;
cin>>s;
arr[i]=s;
H[i].resize(s.length()+1,0);
Hh[i]=h[i]=H[i];
for(int j=1;j<=s.length();j++){
H[i][j]=(H[i][j-1]*29+s[j-1]-'a'+1)%modulo;
h[i][j]=(h[i][j-1]*31+s[j-1]-'a'+1);
Hh[i][j]=(Hh[i][j-1]*53+s[j-1]-'a'+1)%(modulo+2);
}
int K=29,T=31,X=53;
for(int j=1;j<=s.length();j++){
K=29,T=31,X=53;
for(int k=j-1;k>=0;k--){
S.insert((H[i][j]-H[i][k]*K%modulo+modulo)%modulo+(h[i][j]-h[i][k]*T)+(Hh[i][j]-Hh[i][k]*X%(modulo+2)+(modulo+2))%(modulo+2));
K=K*29%modulo;
T=T*31;
X=X*53%(modulo+2);
}
}
for(set<int>::iterator itr=S.begin();itr!=S.end();itr++){
data[*itr]++;
}
}
int ans=0;
for(int i=0;i<n;i++){
ans+=data[H[i].back()+h[i].back()+Hh[i].back()]-1;
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |