Submission #383290

#TimeUsernameProblemLanguageResultExecution timeMemory
383290drekavacIspit (COCI19_ispit)C++14
0 / 90
1276 ms2796 KiB
#include <bits/stdc++.h> #define ll long long int using namespace std; #define ll long long int int NM = 600, p = 31, n, k; ll m = (ll)1<<55; string s; vector< vector<ll> > v(NM); vector<int> ppow(NM, 1); int get(char c){ return c-'a'; } void hashF(int red){ for(int i=0; i+k <= n; i++){ vector<int> kv; for(int j=0; j<k; j++) kv.push_back(get(s[i+j])); sort(kv.begin(), kv.end()); ll ret = 0; for(int j=0; j<k; j++){ ret += kv[j]*ppow[j]; ret = ret % m; } v[red].push_back(ret); } } int main(){ cin.tie(NULL); ios::sync_with_stdio(false); cin >> n >> k; for(int i=1; i<k+2; i++) ppow[i] = (p*ppow[i-1])%m; for(int i=0; i<n; i++){ cin>>s; hashF(i); } int d = v[0].size(); for(int i=0; i<d; i++){ map<ll, int> mapa; for(int j=0; j<n; j++){ mapa[ v[j][i] ]++; if(mapa[ v[j][i] ]==2){ cout<<"DA"; return 0; } } } cout<<"NE"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...