Submission #98894

# Submission time Handle Problem Language Result Execution time Memory
98894 2019-02-27T08:01:01 Z Ort Lozinke (COCI17_lozinke) C++11
100 / 100
469 ms 15212 KB
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<unordered_set>

using namespace std;

unordered_map<string,int> um;
unordered_set<string> us;
vector<string> vs;

int n;
string s;
int sol = 0;

int main() {
	cin >> n;
  	for(int i=0;i<n;i++) {
  		us.clear();
      	cin >> s;
      	vs.push_back(s);
      	for(int j=0;j<s.size();j++)
        	for(int k=1;k<=s.size()-j;k++)
        		if(us.find(s.substr(j,k))==us.end()) {
        			um[s.substr(j,k)] += 1;
          			us.insert(s.substr(j,k));
				}
  	}
  	for(int i=0;i<vs.size();i++) sol += (um[vs[i]] - 1);
  	cout << sol;
  	return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        for(int j=0;j<s.size();j++)
                    ~^~~~~~~~~
lozinke.cpp:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          for(int k=1;k<=s.size()-j;k++)
                      ~^~~~~~~~~~~~
lozinke.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0;i<vs.size();i++) sol += (um[vs[i]] - 1);
                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 300 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 18 ms 768 KB Output is correct
7 Correct 21 ms 1536 KB Output is correct
8 Correct 31 ms 2176 KB Output is correct
9 Correct 96 ms 2392 KB Output is correct
10 Correct 197 ms 7120 KB Output is correct
11 Correct 116 ms 4004 KB Output is correct
12 Correct 436 ms 15200 KB Output is correct
13 Correct 179 ms 3096 KB Output is correct
14 Correct 309 ms 14008 KB Output is correct
15 Correct 469 ms 15212 KB Output is correct
16 Correct 168 ms 1860 KB Output is correct
17 Correct 111 ms 1624 KB Output is correct
18 Correct 66 ms 1648 KB Output is correct
19 Correct 238 ms 8060 KB Output is correct
20 Correct 87 ms 1648 KB Output is correct