Submission #639056

# Submission time Handle Problem Language Result Execution time Memory
639056 2022-09-08T11:54:29 Z inksamurai Lozinke (COCI17_lozinke) C++17
100 / 100
346 ms 16748 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3RhsN1z ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

signed main(){
_3RhsN1z;
	int n;
	cin>>n;
	vec(string) a(n);
	rep(i,n){
		cin>>a[i];
	}
	std::map<string,int> mp;
	rep(i,n){
		string s=a[i];
		vec(string) tmp;
		rep(i,sz(s)){
			string now="";
			rng(j,i,sz(s)){
				now+=s[j];
				tmp.pb(now);
			}
		}
		sort(tmp.begin(),tmp.end());
		tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
		for(auto s:tmp){
			mp[s]+=1;
		}
	}
	int ans=0;
	rep(i,n){
		ans+=mp[a[i]]-1;
	}
	print(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 8 ms 724 KB Output is correct
6 Correct 13 ms 732 KB Output is correct
7 Correct 16 ms 1364 KB Output is correct
8 Correct 31 ms 2284 KB Output is correct
9 Correct 69 ms 2380 KB Output is correct
10 Correct 144 ms 7568 KB Output is correct
11 Correct 110 ms 4276 KB Output is correct
12 Correct 318 ms 16748 KB Output is correct
13 Correct 226 ms 2728 KB Output is correct
14 Correct 247 ms 15312 KB Output is correct
15 Correct 346 ms 16632 KB Output is correct
16 Correct 244 ms 1108 KB Output is correct
17 Correct 102 ms 852 KB Output is correct
18 Correct 76 ms 852 KB Output is correct
19 Correct 219 ms 8692 KB Output is correct
20 Correct 119 ms 1068 KB Output is correct