Submission #472770

# Submission time Handle Problem Language Result Execution time Memory
472770 2021-09-14T09:57:15 Z BidoTeima Lozinke (COCI17_lozinke) C++17
100 / 100
510 ms 16380 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc int tttttt;cin>>tttttt;while(tttttt--)
#define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1])
int main(){
    ACPLS();
    int n;
    cin>>n;
    map<string,int>freq{};
    string arr[n];
    for(int i = 0; i < n; i++){
        cin>>arr[i];
        string s = arr[i];
        map<string,bool>vis{};
        for(int j = 0; j < (int)s.size(); j++){
            string sub;
            for(int k = j; k < (int)s.size(); k++){
                sub+=s[k];
                if(vis[sub])continue;
                vis[sub]=1;
                ++freq[sub];
            }
        }
    }
    int ans=0;
    for(int i = 0; i < n; i++){
        ans+=freq[arr[i]]-1;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 15 ms 700 KB Output is correct
6 Correct 22 ms 600 KB Output is correct
7 Correct 23 ms 1328 KB Output is correct
8 Correct 36 ms 2168 KB Output is correct
9 Correct 91 ms 2308 KB Output is correct
10 Correct 225 ms 7376 KB Output is correct
11 Correct 155 ms 4200 KB Output is correct
12 Correct 510 ms 16380 KB Output is correct
13 Correct 325 ms 2600 KB Output is correct
14 Correct 391 ms 14964 KB Output is correct
15 Correct 472 ms 16300 KB Output is correct
16 Correct 293 ms 972 KB Output is correct
17 Correct 66 ms 908 KB Output is correct
18 Correct 51 ms 920 KB Output is correct
19 Correct 330 ms 8448 KB Output is correct
20 Correct 155 ms 1092 KB Output is correct