Submission #116896

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

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<=adj[i].length()-1;k++)
               ~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
                ~^~~~~~~~~~~~~~~~~~~~~~~~~
lozinke.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 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 15 ms 768 KB Output isn't correct
6 Correct 42 ms 760 KB Output is correct
7 Incorrect 42 ms 1528 KB Output isn't correct
8 Correct 27 ms 2304 KB Output is correct
9 Execution timed out 1072 ms 2672 KB Time limit exceeded
10 Correct 149 ms 7720 KB Output is correct
11 Execution timed out 1070 ms 2544 KB Time limit exceeded
12 Correct 374 ms 16880 KB Output is correct
13 Execution timed out 1080 ms 1904 KB Time limit exceeded
14 Execution timed out 1071 ms 5232 KB Time limit exceeded
15 Correct 395 ms 16744 KB Output is correct
16 Incorrect 505 ms 1528 KB Output isn't correct
17 Runtime error 66 ms 2668 KB Execution killed with signal 8 (could be triggered by violating memory limits)
18 Runtime error 51 ms 2668 KB Execution killed with signal 8 (could be triggered by violating memory limits)
19 Execution timed out 1056 ms 3260 KB Time limit exceeded
20 Runtime error 469 ms 2664 KB Execution killed with signal 8 (could be triggered by violating memory limits)