답안 #116910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116910 2019-06-14T04:13:51 Z TienDungz Lozinke (COCI17_lozinke) C++14
0 / 100
535 ms 29984 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int res=0,n;
string t;
vector<string> adj;
unordered_map<string,int> cnt,cnt2;
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++)
	{
		unordered_map<string,bool> cur;
		for(int k=1;k<=adj[i].length()-1;k++)
		{
			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]]++;
	}
	for(int i=n-1;i>=0;i--)
	{
		unordered_map<string,bool> cur;
		for(int k=1;k<=adj[i].length()-1;k++)
		{
			string s;
			for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
			{
				s=adj[i].substr(j,k);
				if(cur[s]==false) 
				{
					res+=cnt2[s];
					cur[s]=true;
				}
			}
		}
		cnt2[adj[i]]++;
	}
	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:27: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:42:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<=adj[i].length()-1;k++)
               ~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:45:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
                ~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 4 ms 512 KB Output isn't correct
5 Incorrect 13 ms 1024 KB Output isn't correct
6 Incorrect 17 ms 1024 KB Output isn't correct
7 Incorrect 25 ms 2688 KB Output isn't correct
8 Incorrect 33 ms 3968 KB Output isn't correct
9 Incorrect 116 ms 4080 KB Output isn't correct
10 Incorrect 191 ms 13508 KB Output isn't correct
11 Incorrect 179 ms 7408 KB Output isn't correct
12 Incorrect 535 ms 29984 KB Output isn't correct
13 Incorrect 252 ms 4168 KB Output isn't correct
14 Incorrect 381 ms 27344 KB Output isn't correct
15 Incorrect 518 ms 29644 KB Output isn't correct
16 Incorrect 225 ms 1528 KB Output isn't correct
17 Incorrect 138 ms 1528 KB Output isn't correct
18 Incorrect 119 ms 1528 KB Output isn't correct
19 Incorrect 315 ms 15080 KB Output isn't correct
20 Incorrect 302 ms 1528 KB Output isn't correct