답안 #914711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914711 2024-01-22T15:03:28 Z racsosabe Lozinke (COCI17_lozinke) C++14
100 / 100
287 ms 16728 KB
#include<bits/stdc++.h>
using namespace::std;

const int N = 20000 + 5;

int n;
string s[N];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	map<string, int> frec;
	for(int i = 1; i <= n; i++) {
		cin >> s[i];
		frec[s[i]] += 1;
	}
	long long res = 0;
	for(int id = 1; id <= n; id++) {
		set<string> used;
		for(int i = 0; i < s[id].size(); i++) {
			string cur = "";
			for(int j = i; j < s[id].size(); j++) {
				cur.push_back(s[id][j]);
				if(!used.count(cur)) {
					used.emplace(cur);
					res += frec[cur];
				}
			}
		}
		res -= 1;
	}
	cout << res << endl;
	return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i = 0; i < s[id].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
lozinke.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |    for(int j = i; j < s[id].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 7 ms 1372 KB Output is correct
6 Correct 12 ms 1384 KB Output is correct
7 Correct 15 ms 2140 KB Output is correct
8 Correct 24 ms 3028 KB Output is correct
9 Correct 60 ms 2900 KB Output is correct
10 Correct 122 ms 7764 KB Output is correct
11 Correct 97 ms 4432 KB Output is correct
12 Correct 268 ms 16728 KB Output is correct
13 Correct 184 ms 2896 KB Output is correct
14 Correct 185 ms 14932 KB Output is correct
15 Correct 287 ms 16584 KB Output is correct
16 Correct 194 ms 1368 KB Output is correct
17 Correct 39 ms 1568 KB Output is correct
18 Correct 29 ms 1364 KB Output is correct
19 Correct 188 ms 8788 KB Output is correct
20 Correct 93 ms 1372 KB Output is correct