Submission #116878

# Submission time Handle Problem Language Result Execution time Memory
116878 2019-06-14T03:16:04 Z TienDungz Lozinke (COCI17_lozinke) C++14
0 / 100
1000 ms 33388 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int res=0,n,fact[300005];
string t;
vector<string> adj;
map<string,int> cnt;
map<string,bool> cur[300005];
bool cmp (string a,string b)
{
	return a.length()<b.length();
}
signed main()
{
	cin>>n;
	fact[0]=1;
	for(int i=1;i<=200005;i++)
	fact[i]=fact[i-1]*i;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		adj.push_back(t);
	}
	sort(adj.begin(),adj.end(),cmp);
	adj.push_back("b");
	for(int i=0;i<n;i++)
	{
		for(int k=1;k<=adj[i].length()-1;k++)
		{
			string s[200005];
			for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
			{
				s[j]=adj[i].substr(j,k);
				if(cnt[s[j]]>=1&&cur[i][s[j]]==false) 
				{
					res+=cnt[s[j]];
					cur[i][s[j]]=true;
				}
			}
		}
		cnt[adj[i]]++;
		if(cnt[adj[i]]>=2&&adj[i+1].length()!=adj[i].length())
		{
			res+=fact[cnt[adj[i]]]/fact[cnt[adj[i]]-2];
		}
	}
	cout<<res;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<=adj[i].length()-1;k++)
               ~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:31:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
                ~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 22264 KB Output isn't correct
2 Incorrect 81 ms 22272 KB Output isn't correct
3 Incorrect 503 ms 22520 KB Output isn't correct
4 Execution timed out 1068 ms 22520 KB Time limit exceeded
5 Execution timed out 1040 ms 22764 KB Time limit exceeded
6 Execution timed out 1074 ms 22400 KB Time limit exceeded
7 Execution timed out 1063 ms 22776 KB Time limit exceeded
8 Execution timed out 1069 ms 22748 KB Time limit exceeded
9 Runtime error 39 ms 32624 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Execution timed out 1083 ms 22868 KB Time limit exceeded
11 Runtime error 41 ms 33016 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Execution timed out 1073 ms 23284 KB Time limit exceeded
13 Execution timed out 1080 ms 23028 KB Time limit exceeded
14 Runtime error 45 ms 33388 KB Execution killed with signal 8 (could be triggered by violating memory limits)
15 Execution timed out 1077 ms 23048 KB Time limit exceeded
16 Execution timed out 1069 ms 23020 KB Time limit exceeded
17 Execution timed out 1054 ms 22960 KB Time limit exceeded
18 Execution timed out 1063 ms 23020 KB Time limit exceeded
19 Execution timed out 1054 ms 23028 KB Time limit exceeded
20 Execution timed out 1068 ms 23020 KB Time limit exceeded