# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
554689 | 2022-04-29T07:40:16 Z | new_acc | Lozinke (COCI17_lozinke) | C++14 | 143 ms | 41132 KB |
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod=998244353; const ll mod2=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; int t[N]; string s[N]; unordered_map<ull,int> m; unordered_map<ull,bool> m2; void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>s[i]; ull akth=0; for(int j=0;j<s[i].size();j++) akth=akth*p2+s[i][j]; m[akth]++; } ll res=0; for(int i=1;i<=n;i++){ for(int j=0;j<s[i].size();j++){ ull akth=0; for(int k=j;k<s[i].size();k++){ akth=(akth*p2+s[i][k]); if(m2[akth]) continue; res+=m[akth]; m2[akth]=1; } } m2.clear(); res--; } cout<<res<<"\n"; } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 31616 KB | Output is correct |
2 | Correct | 16 ms | 31580 KB | Output is correct |
3 | Correct | 16 ms | 31572 KB | Output is correct |
4 | Correct | 16 ms | 31572 KB | Output is correct |
5 | Correct | 22 ms | 31800 KB | Output is correct |
6 | Correct | 20 ms | 31812 KB | Output is correct |
7 | Correct | 22 ms | 32212 KB | Output is correct |
8 | Correct | 25 ms | 32724 KB | Output is correct |
9 | Correct | 40 ms | 32676 KB | Output is correct |
10 | Correct | 58 ms | 36256 KB | Output is correct |
11 | Correct | 50 ms | 33936 KB | Output is correct |
12 | Correct | 113 ms | 41056 KB | Output is correct |
13 | Correct | 72 ms | 32684 KB | Output is correct |
14 | Correct | 85 ms | 41132 KB | Output is correct |
15 | Correct | 143 ms | 41076 KB | Output is correct |
16 | Correct | 77 ms | 31712 KB | Output is correct |
17 | Correct | 43 ms | 31568 KB | Output is correct |
18 | Correct | 36 ms | 31572 KB | Output is correct |
19 | Correct | 74 ms | 36272 KB | Output is correct |
20 | Correct | 50 ms | 31700 KB | Output is correct |