답안 #116909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116909 2019-06-14T04:12:13 Z TienDungz Lozinke (COCI17_lozinke) C++14
0 / 100
467 ms 15136 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;
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+=cnt[s];
					cur[s]=true;
				}
			}
		}
		cnt[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 2 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Incorrect 11 ms 768 KB Output isn't correct
6 Incorrect 16 ms 768 KB Output isn't correct
7 Incorrect 23 ms 1600 KB Output isn't correct
8 Incorrect 30 ms 2176 KB Output isn't correct
9 Incorrect 106 ms 2416 KB Output isn't correct
10 Incorrect 179 ms 6988 KB Output isn't correct
11 Incorrect 175 ms 4328 KB Output isn't correct
12 Incorrect 464 ms 15132 KB Output isn't correct
13 Incorrect 230 ms 2536 KB Output isn't correct
14 Incorrect 353 ms 13976 KB Output isn't correct
15 Incorrect 467 ms 15136 KB Output isn't correct
16 Incorrect 262 ms 1528 KB Output isn't correct
17 Incorrect 137 ms 1528 KB Output isn't correct
18 Incorrect 110 ms 1504 KB Output isn't correct
19 Incorrect 292 ms 7944 KB Output isn't correct
20 Incorrect 167 ms 1528 KB Output isn't correct