Submission #80269

#TimeUsernameProblemLanguageResultExecution timeMemory
80269pamajLozinke (COCI17_lozinke)C++14
40 / 100
1091 ms2752 KiB
#include <bits/stdc++.h>
using namespace std;


// struct node
// {
// 	bool ok = false;
// 	node *b[26];
// };

// bool find(const string& s)
// {

// }

// bool insert(const string& s, node* a)
// {
// 	for(auto u : s)
// 	{

// 	}
// }


bool find(const string& a, const string& b)
{
	if(a.size() < b.size()) return false;
	for(int i = 0; i < a.size(); i++)
	{
		bool ok = false;
		for(int j = 0; j < b.size(); j++)
		{
			if(i + j >= a.size()) break;
			if(a[i + j] != b[j])
				break;
			if(j == b.size() - 1) return true;
		}
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int n;
	cin >> n;

	vector<string> ps;

	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		string s; 
		cin >> s;
		ps.push_back(s);
	}

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i == j) continue;
			if(find(ps[i],ps[j])) ans++;
		}
	}

	cout << ans << "\n";
}

Compilation message (stderr)

lozinke.cpp: In function 'bool find(const string&, const string&)':
lozinke.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < a.size(); i++)
                 ~~^~~~~~~~~~
lozinke.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < b.size(); j++)
                  ~~^~~~~~~~~~
lozinke.cpp:33:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i + j >= a.size()) break;
       ~~~~~~^~~~~~~~~~~
lozinke.cpp:36:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j == b.size() - 1) return true;
       ~~^~~~~~~~~~~~~~~
lozinke.cpp:30:8: warning: unused variable 'ok' [-Wunused-variable]
   bool ok = false;
        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...