답안 #472780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472780 2021-09-14T10:14:50 Z _L__ Lozinke (COCI17_lozinke) C++17
100 / 100
889 ms 16452 KB
// This code is written by _L__
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 1e5+300, inf = 1e18;
const ld E = 1e-6;
#define ff first
#define ss second

int main(void){
    F_word;
    int n; cin >> n;
    string arr[n];
    map<string, int> freq;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        map<string, bool> shown;
        for(int j = 0; j < arr[i].size(); ++j){
            string s = "";
            for(int k = j; k < arr[i].size(); ++k){
                s += arr[i][k];
                if(!shown[s]){freq[s]++;shown[s] = 1;}
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < arr[i].size(); ++j){
            string s = "";
            for(int k = j; k < arr[i].size(); ++k){
                s += arr[i][k];
                freq[s]--;
            }
        }
        //if(freq[arr[i]]) cout << arr[i] << endl; 
        ans += freq[arr[i]];
        for(int j = 0; j < arr[i].size(); ++j){
            string s = "";
            for(int k = j; k < arr[i].size(); ++k){
                s += arr[i][k];
                freq[s]++;
            }
        }
    }
    cout << ans << endl;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int j = 0; j < arr[i].size(); ++j){
      |                        ~~^~~~~~~~~~~~~~~
lozinke.cpp:27:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             for(int k = j; k < arr[i].size(); ++k){
      |                            ~~^~~~~~~~~~~~~~~
lozinke.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = 0; j < arr[i].size(); ++j){
      |                        ~~^~~~~~~~~~~~~~~
lozinke.cpp:37:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(int k = j; k < arr[i].size(); ++k){
      |                            ~~^~~~~~~~~~~~~~~
lozinke.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int j = 0; j < arr[i].size(); ++j){
      |                        ~~^~~~~~~~~~~~~~~
lozinke.cpp:46:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for(int k = j; k < arr[i].size(); ++k){
      |                            ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 17 ms 724 KB Output is correct
6 Correct 30 ms 712 KB Output is correct
7 Correct 40 ms 1356 KB Output is correct
8 Correct 65 ms 2252 KB Output is correct
9 Correct 175 ms 2400 KB Output is correct
10 Correct 404 ms 7512 KB Output is correct
11 Correct 304 ms 4160 KB Output is correct
12 Correct 840 ms 16452 KB Output is correct
13 Correct 556 ms 2784 KB Output is correct
14 Correct 555 ms 14828 KB Output is correct
15 Correct 889 ms 16324 KB Output is correct
16 Correct 546 ms 1080 KB Output is correct
17 Correct 135 ms 844 KB Output is correct
18 Correct 91 ms 912 KB Output is correct
19 Correct 574 ms 8520 KB Output is correct
20 Correct 285 ms 972 KB Output is correct