Submission #116894

# Submission time Handle Problem Language Result Execution time Memory
116894 2019-06-14T03:42:36 Z TienDungz Lozinke (COCI17_lozinke) C++14
55 / 100
376 ms 41300 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int res=0,n;
string t;
vector<int> bump;
vector<string> adj,ditme;
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);
	for(int i=0;i<n;i++)
	{
		for(int k=1;k<=adj[i].length()-1;k++)
		{
			map<string,bool> cur;
			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;
					ditme.push_back(s);
				}
			}
		}
		cnt[adj[i]]++;
		if(cnt[adj[i]]>=2)
		{
			bump.push_back(i);
		}
	}
	map<string,bool> cur;
	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:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<=adj[i].length()-1;k++)
               ~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:28: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:46: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 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 11 ms 1148 KB Output isn't correct
6 Correct 13 ms 1256 KB Output is correct
7 Incorrect 21 ms 2272 KB Output isn't correct
8 Correct 25 ms 2296 KB Output is correct
9 Runtime error 109 ms 13744 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Correct 132 ms 7664 KB Output is correct
11 Runtime error 173 ms 21528 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Correct 355 ms 16944 KB Output is correct
13 Correct 197 ms 6392 KB Output is correct
14 Runtime error 291 ms 41300 KB Execution killed with signal 8 (could be triggered by violating memory limits)
15 Correct 376 ms 16744 KB Output is correct
16 Incorrect 136 ms 2924 KB Output isn't correct
17 Runtime error 66 ms 2540 KB Execution killed with signal 8 (could be triggered by violating memory limits)
18 Runtime error 62 ms 6396 KB Execution killed with signal 8 (could be triggered by violating memory limits)
19 Correct 355 ms 11736 KB Output is correct
20 Runtime error 157 ms 18248 KB Execution killed with signal 8 (could be triggered by violating memory limits)