이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |