답안 #515777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515777 2022-01-19T16:04:07 Z perchuts Lozinke (COCI17_lozinke) C++17
100 / 100
232 ms 18696 KB
#include <bits/stdc++.h>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

string v[maxn];
int main(){_
    int n;cin>>n;
    unordered_map<string,int>pwords;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        pwords[v[i]]++;
    }    
    ll ans = 0;
    for(int i=1;i<=n;i++){
        set<string>vis;
        for(int j=0;j<sz(v[i]);j++){
            string tmp = "";
            for(int k=j;k<sz(v[i]);k++){
                tmp+=v[i][k];
                if(vis.count(tmp)==0)ans+=1LL*pwords[tmp];
                vis.insert(tmp);
            }
        }
    }
    cout<<ans-n<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 2 ms 3404 KB Output is correct
3 Correct 2 ms 3368 KB Output is correct
4 Correct 2 ms 3404 KB Output is correct
5 Correct 8 ms 3788 KB Output is correct
6 Correct 11 ms 3660 KB Output is correct
7 Correct 14 ms 4572 KB Output is correct
8 Correct 25 ms 5284 KB Output is correct
9 Correct 49 ms 5196 KB Output is correct
10 Correct 94 ms 10704 KB Output is correct
11 Correct 78 ms 6976 KB Output is correct
12 Correct 232 ms 18696 KB Output is correct
13 Correct 148 ms 5144 KB Output is correct
14 Correct 167 ms 18352 KB Output is correct
15 Correct 229 ms 18432 KB Output is correct
16 Correct 173 ms 3580 KB Output is correct
17 Correct 68 ms 3444 KB Output is correct
18 Correct 50 ms 3432 KB Output is correct
19 Correct 147 ms 10820 KB Output is correct
20 Correct 100 ms 3568 KB Output is correct