Submission #138623

#TimeUsernameProblemLanguageResultExecution timeMemory
138623KCSCLozinke (COCI17_lozinke)C++14
95 / 100
1045 ms16760 KiB
#include <bits/stdc++.h> using namespace std; const int DIM = 20005; string str[DIM]; char aux[DIM]; map<string, int> mmp; void solve(int n, int &ans) { mmp.clear(); for (int i = 1; i <= n; ++i) { ans += mmp[str[i]]; set<string> mst; for (int p1 = 0; p1 < str[i].length(); ++p1) for (int p2 = p1; p2 < str[i].length(); ++p2) mst.insert(str[i].substr(p1, p2 - p1 + 1)); for (string s : mst) mmp[s]++; } } int main(void) { #ifdef HOME freopen("lozinke.in", "r", stdin); freopen("lozinke.out", "w", stdout); #endif int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", aux + 1); int m = strlen(aux + 1); for (int j = 1; j <= m; ++j) str[i].push_back(aux[j]); } int ans = 0; solve(n, ans); reverse(str + 1, str + n + 1); solve(n, ans); cout << ans; return 0; }

Compilation message (stderr)

lozinke.cpp: In function 'void solve(int, int&)':
lozinke.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int p1 = 0; p1 < str[i].length(); ++p1)
                    ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:16:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int p2 = p1; p2 < str[i].length(); ++p2)
                      ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp: In function 'int main()':
lozinke.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
lozinke.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", aux + 1);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...