답안 #843684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843684 2023-09-04T12:17:14 Z nihaddhuseynli Lozinke (COCI17_lozinke) C++14
100 / 100
119 ms 16256 KB
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int MAXN = 2e4 + 10;

int n;

string l[MAXN];

unordered_set<string> s;
unordered_map<string, int> cnt;

int main(void) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
    s.clear();

    for (int j = 0; j < (int) l[i].size(); ++j) {
      string curr;
      for (int k = j; k < (int) l[i].size(); ++k) {
        curr.push_back(l[i][k]);
        s.insert(curr);
      }
    }

    for (auto &x : s)
      cnt[x]++;
  }

  int sol = 0;
  for (auto &x : l)
    sol += cnt[x];

  cout << sol - n << endl;

  return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 4 ms 1368 KB Output is correct
6 Correct 5 ms 1368 KB Output is correct
7 Correct 6 ms 1880 KB Output is correct
8 Correct 10 ms 2740 KB Output is correct
9 Correct 25 ms 2828 KB Output is correct
10 Correct 47 ms 8272 KB Output is correct
11 Correct 37 ms 4524 KB Output is correct
12 Correct 114 ms 16256 KB Output is correct
13 Correct 67 ms 2776 KB Output is correct
14 Correct 91 ms 15812 KB Output is correct
15 Correct 119 ms 16112 KB Output is correct
16 Correct 75 ms 1112 KB Output is correct
17 Correct 44 ms 860 KB Output is correct
18 Correct 30 ms 856 KB Output is correct
19 Correct 71 ms 8384 KB Output is correct
20 Correct 40 ms 1184 KB Output is correct