Submission #1067187

#TimeUsernameProblemLanguageResultExecution timeMemory
1067187Celebi_276Lozinke (COCI17_lozinke)C++17
100 / 100
303 ms16748 KiB
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define MultiTest(k) int k; cin >> k; while (k--)
#define all(v) v.begin(), v.end()
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>
#define NAME ""

string s[20022];
int n, Z(0);
map <string, int> mp, ok;

void process (string s) {
  int l = s.length();
  vector <string> C;
  for (int i = 0; i < l; i++)
    for (int j = i; j < l; j++) {
      string t = s.substr(i, j - i + 1);
      if (!ok[t]) C.push_back(t);
      ok[t] = 1;
    }
  for (string t : C) mp[t]++;
  ok.clear();
}

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  if (fopen(NAME".INP", "r"))
  {
    freopen(NAME".INP", "r", stdin);
    freopen(NAME".OUT", "w", stdout);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    process(s[i]);
  }
  for (int i = 1; i <= n; i++) Z += mp[s[i]];
  cout << Z - n;
  return 0;
}

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:40:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     freopen(NAME".INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lozinke.cpp:41:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     freopen(NAME".OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...