Submission #116887

# Submission time Handle Problem Language Result Execution time Memory
116887 2019-06-14T03:30:19 Z TienDungz Doktor (COCI17_doktor) C++14
0 / 100
1000 ms 131072 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int res=0,n,fact[200005];
string t;
vector<int> bump;
vector<string> adj,ditme;
map<string,int> cnt;
map<string,bool> cur[200005];
bool cmp (string a,string b)
{
	return a.length()<b.length();
}
signed main()
{
	cin>>n;
	fact[0]=1;
	for(int i=1;i<=200004;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);
	for(int i=0;i<n;i++)
	{
		for(int k=1;k<=adj[i].length()-1;k++)
		{
			string s[20];
			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;
					ditme.push_back(s[j]);
				}
			}
		}
		cnt[adj[i]]++;
		if(cnt[adj[i]]>=2)
		{
			bump.push_back(i);
		}
	}
	for(int i=0;i<bump.size();i++)
	{
		if(cur[200002][adj[bump[i]]]==false)
		{
			res+=fact[cnt[adj[bump[i]]]]/fact[cnt[adj[bump[i]]]-2];
			cur[200002][adj[bump[i]]]=true;
		}
	}
	cout<<res;
}

Compilation message

doktor.cpp: In function 'int main()':
doktor.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<=adj[i].length()-1;k++)
               ~^~~~~~~~~~~~~~~~~~~
doktor.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++)
                ~^~~~~~~~~~~~~~~~~~~~~~~~~
doktor.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<bump.size();i++)
              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 11264 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 11264 KB Integer 41 violates the range [1, 32]
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 11520 KB Integer 1128 violates the range [1, 321]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 12852 KB Integer 11973 violates the range [1, 2000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 15212 KB Integer 31388 violates the range [1, 4500]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 16476 KB Integer 34281 violates the range [1, 4853]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 21480 KB Integer 74686 violates the range [1, 10000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 131072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 118320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 123764 KB Time limit exceeded
2 Halted 0 ms 0 KB -