답안 #570523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570523 2022-05-30T11:15:36 Z AGE Ispit (COCI19_ispit) C++14
0 / 90
705 ms 65536 KB
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back

using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;
int hashh[505][505],cnt[500][27];

string s[N];

int mult(int x,int y){

    return ((x%mod)*(y%mod))%mod;

}

int minuss(int x,int y){

    return ((x%mod)-(y%mod)+mod)%mod;

}

int summ(int x,int y){
    return((x%mod)+(y%mod))%mod;
}


void compute_hash(string s,int index){

    const int pp=31;
    int p_pow=1;

    hashh[index][0]=s[0]-'a'+1;
    for(int i=1;i<s.size();i++){
        p_pow=mult(p_pow,pp);
        hashh[index][i]=summ(hashh[index][i-1],mult(s[i]-'a'+1,p_pow));
    }


}
main()
{

    int n,m;
    cin>>n>>m;


    for(int i=0;i<n;i++)
        cin>>s[i];

    for(int i=0;i<n;i++){
        for(int j=i;j<i+m;j++){
            for(int k=0;k<n;k++){
                cnt[i][s[k][j]-'a']++;
            }
        }
    }

    for(int i=0;i<n;i++){
        compute_hash(s[i],i);
    }

    for(int i=0;i<n;i++){
        int ok=0;

        for(int j=0;j<26;j++){
            ok+=(cnt[i][j]/2);
        }

        if(ok<m)
            continue;

        for(int j=0;j<n;j++){
            for(int k=j+1;j<n;k++){

                if((i==0||hashh[j][i-1]==hashh[k][i-1])&&(hashh[j][n-1]-hashh[j][i+m-1]==hashh[j][n-1]-hashh[j][i+m-1])){

                    cout<<"DA"<<endl;
                    exit(0);

                }
            }
        }
    }

    cout<<"NE"<<endl;

    return 0;
}
/*
4 2
abcd
acbd
unee
asds
*/

Compilation message

ispit.cpp: In function 'void compute_hash(std::string, long long int)':
ispit.cpp:36:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=1;i<s.size();i++){
      |                 ~^~~~~~~~~
ispit.cpp: At global scope:
ispit.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main()
      | ^~~~
ispit.cpp: In function 'int main()':
ispit.cpp:78:88: warning: self-comparison always evaluates to true [-Wtautological-compare]
   78 |                 if((i==0||hashh[j][i-1]==hashh[k][i-1])&&(hashh[j][n-1]-hashh[j][i+m-1]==hashh[j][n-1]-hashh[j][i+m-1])){
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 63900 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 31572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 31564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 32460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 84 ms 65536 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 32420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 32428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 673 ms 34068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 705 ms 34152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 647 ms 34152 KB Output isn't correct
2 Halted 0 ms 0 KB -