Submission #155205

# Submission time Handle Problem Language Result Execution time Memory
155205 2019-09-27T06:29:42 Z GoldNextYear Lozinke (COCI17_lozinke) C++14
100 / 100
596 ms 16792 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll inf=1e18*4;
const ld pai=acos(-1);
int n,ans;
string s[20009];
map<string,int>mp;
map<string,int>done;
int main(){
        fast;
        cin>>n;
        for(int i=0;i<n;i++)cin>>s[i],mp[s[i]]++;
        for(int i=0;i<n;i++){
                mp[s[i]]--;
                string x=s[i];
                for(int j=0;j<x.size();j++){
                        string ret="";
                        for(int k=j;k<x.size();k++){
                                ret+=x[k];
                                if(!done[ret]){
                                        ans+=mp[ret];
                                        done[ret]=1;
                                }
                        }
                }
                done.clear();
                mp[s[i]]++;
        }
        cout<<ans<<endl;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:39:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0;j<x.size();j++){
                             ~^~~~~~~~~
lozinke.cpp:41:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                         for(int k=j;k<x.size();k++){
                                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 2 ms 888 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 4 ms 1016 KB Output is correct
5 Correct 16 ms 1400 KB Output is correct
6 Correct 29 ms 1272 KB Output is correct
7 Correct 32 ms 2040 KB Output is correct
8 Correct 49 ms 2936 KB Output is correct
9 Correct 128 ms 2884 KB Output is correct
10 Correct 263 ms 7928 KB Output is correct
11 Correct 210 ms 4600 KB Output is correct
12 Correct 563 ms 16792 KB Output is correct
13 Correct 394 ms 2940 KB Output is correct
14 Correct 405 ms 15096 KB Output is correct
15 Correct 596 ms 16564 KB Output is correct
16 Correct 393 ms 1276 KB Output is correct
17 Correct 61 ms 1272 KB Output is correct
18 Correct 46 ms 1148 KB Output is correct
19 Correct 420 ms 8752 KB Output is correct
20 Correct 188 ms 1400 KB Output is correct