답안 #165182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165182 2019-11-25T16:26:12 Z theStaticMind Lozinke (COCI17_lozinke) C++14
95 / 100
370 ms 17272 KB
#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];
      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);
            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)%mod;
            }
            int K=29,T=31;
            for(int j=1;j<=s.length();j++){
                  K=29,T=31;
                  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%mod+mod)%mod);
                        K=K*29%modulo;
                        T=T*31%mod;
                  }
            }
            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()]-1;
      }
      cout<<ans;
}

Compilation message

lozinke.cpp: In function 'int32_t main()':
lozinke.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=1;j<=s.length();j++){
                         ~^~~~~~~~~~~~
lozinke.cpp:34:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=1;j<=s.length();j++){
                         ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 8 ms 888 KB Output is correct
6 Correct 11 ms 1016 KB Output is correct
7 Correct 16 ms 1528 KB Output is correct
8 Correct 29 ms 2296 KB Output is correct
9 Correct 58 ms 3832 KB Output is correct
10 Correct 142 ms 8164 KB Output is correct
11 Correct 103 ms 6140 KB Output is correct
12 Incorrect 353 ms 16768 KB Output isn't correct
13 Correct 162 ms 6504 KB Output is correct
14 Correct 259 ms 15700 KB Output is correct
15 Correct 370 ms 17272 KB Output is correct
16 Correct 152 ms 5880 KB Output is correct
17 Correct 50 ms 5624 KB Output is correct
18 Correct 36 ms 5240 KB Output is correct
19 Correct 225 ms 10832 KB Output is correct
20 Correct 82 ms 4856 KB Output is correct