Submission #712768

#TimeUsernameProblemLanguageResultExecution timeMemory
712768aVeLozinke (COCI17_lozinke)C++14
100 / 100
375 ms16584 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define mp make_pair #define pb push_back using namespace std; ll set_on(int n, int k){ return (n |= 1 << k); } ll set_off(int n, int k){ return (n &= ~(1UL << k)); } bool check_bit(int n, int k){ int bit = (n >> k) & 1U; if(bit == 1) return true; return false; } vector<char> next[11]; // next[0] - first characters int add[11][26]; vector<string> pass; int n; bool comp(string& A, string& B){ if(A.size() < B.size()) return true; return false; } int main(){ cin>>n; for(int i = 0; i < n; i++){ string str; cin>>str; pass.pb(str); } sort(pass.begin(), pass.end(), comp); int ans = 0; map<string, int> seen; for(int i = 0; i < n; i++){ string str = pass[i]; map<string,int> done; ans+= seen[str]; for(int j = 0; j < str.size(); j++){ for(int k = j; k < str.size(); k++){ string check; for(int z = j; z <= k; z++) check.pb(str[z]); if(done[check] == 0 && seen[check]>0){ //cout<<str<<" "<<check<<endl; done[check] = 1; ans += seen[check]; } } } seen[str]++; } cout<<ans<<endl; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int j = 0; j < str.size(); j++){
      |                  ~~^~~~~~~~~~~~
lozinke.cpp:46:21: 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 < str.size(); k++){
      |                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...