Submission #1078666

# Submission time Handle Problem Language Result Execution time Memory
1078666 2024-08-28T03:51:48 Z khactrung1912 Lozinke (COCI17_lozinke) C++14
40 / 100
1000 ms 1084 KB
#include <bits/stdc++.h>
using namespace std;

int n, ans;
string st[20004];

bool check(string x, string y)
{
	if (y.find(x)!=-1) return true;
	return false;
}

void sub1()
{
	ans = 0;

	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			if (i!=j && st[j].size()>=st[i].size() && check(st[i],st[j])) ans++;

	cout << ans;			
}

void sub2()
{
	ans = 0;

	for (int i=1; i<n; i++)
		for (int j=i+1; j<=n; j++)
		{
			if (st[i].size()>=st[j].size() && check(st[j],st[i])) ans++;
			if (st[j].size()>=st[i].size() && check(st[i],st[j])) ans++;
		}

	cout << ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	//freopen("PASS.INP","r",stdin);
	//freopen("PASS.OUT","w",stdout);

	cin >> n;
	for (int i=1; i<=n; i++) cin >> st[i];

	if (n<=1000) sub1(); else sub2();

}

Compilation message

lozinke.cpp: In function 'bool check(std::string, std::string)':
lozinke.cpp:9:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |  if (y.find(x)!=-1) return true;
      |      ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 856 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 21 ms 1084 KB Output is correct
6 Correct 46 ms 1064 KB Output is correct
7 Correct 76 ms 860 KB Output is correct
8 Correct 65 ms 860 KB Output is correct
9 Execution timed out 1072 ms 860 KB Time limit exceeded
10 Execution timed out 1018 ms 856 KB Time limit exceeded
11 Execution timed out 1038 ms 860 KB Time limit exceeded
12 Execution timed out 1069 ms 860 KB Time limit exceeded
13 Execution timed out 1064 ms 860 KB Time limit exceeded
14 Execution timed out 1022 ms 856 KB Time limit exceeded
15 Execution timed out 1044 ms 856 KB Time limit exceeded
16 Execution timed out 1067 ms 860 KB Time limit exceeded
17 Execution timed out 1020 ms 856 KB Time limit exceeded
18 Execution timed out 1055 ms 860 KB Time limit exceeded
19 Execution timed out 1037 ms 860 KB Time limit exceeded
20 Execution timed out 1069 ms 860 KB Time limit exceeded