Submission #625248

# Submission time Handle Problem Language Result Execution time Memory
625248 2022-08-09T17:17:19 Z MODDI Lozinke (COCI17_lozinke) C++14
100 / 100
364 ms 16644 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
ll set_on(int n, int k){
	return (n |= 1 << k);
}
ll set_off(int n, int k){
	return (n &= ~(1UL << k));
}
bool check_bit(int n, int k){
	int bit = (n >> k) & 1U;
	if(bit == 1)
		return true;
	return false;
}
vector<char> next[11]; // next[0] - first characters
int add[11][26];
vector<string> pass;
int n;
bool comp(string& A, string& B){
	if(A.size() < B.size())
		return true;
	return false;
}
int main(){
	cin>>n;
	for(int i = 0; i < n; i++){
		string str;
		cin>>str;
		pass.pb(str);
	}
	sort(pass.begin(), pass.end(), comp);
	int ans = 0;
	map<string, int> seen;
	for(int i = 0; i < n; i++){
		string str = pass[i];
		map<string,int> done;
		ans+= seen[str];
		for(int j = 0; j < str.size(); j++){
			for(int k = j; k < str.size(); k++){
				string check;
				for(int z = j; z <= k; z++)
					check.pb(str[z]);
				if(done[check] == 0 && seen[check]>0){
					//cout<<str<<" "<<check<<endl;
					done[check] = 1;
					ans += seen[check];
				}
			}
		}
		seen[str]++;
	}
	cout<<ans<<endl;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int j = 0; j < str.size(); j++){
      |                  ~~^~~~~~~~~~~~
lozinke.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int k = j; k < str.size(); k++){
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 2 ms 304 KB Output is correct
5 Correct 10 ms 712 KB Output is correct
6 Correct 15 ms 724 KB Output is correct
7 Correct 21 ms 1468 KB Output is correct
8 Correct 28 ms 2284 KB Output is correct
9 Correct 93 ms 2452 KB Output is correct
10 Correct 142 ms 7488 KB Output is correct
11 Correct 149 ms 4404 KB Output is correct
12 Correct 364 ms 16644 KB Output is correct
13 Correct 239 ms 2840 KB Output is correct
14 Correct 245 ms 15016 KB Output is correct
15 Correct 363 ms 16372 KB Output is correct
16 Correct 252 ms 1612 KB Output is correct
17 Correct 96 ms 1612 KB Output is correct
18 Correct 71 ms 1560 KB Output is correct
19 Correct 241 ms 8744 KB Output is correct
20 Correct 161 ms 1612 KB Output is correct