답안 #48934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48934 2018-05-20T06:00:54 Z leehosu01 백신 (KOI13_vaccine) C++17
0 / 24
42 ms 2028 KB
#include<bits/stdc++.h>
using namespace std;
bitset<2500>ext;
bool phase=0;
typedef long long ll;
ll p1=10061,p2=100000007,n1=396,n2=117;
ll PW(ll X,ll Y,ll P)
{
    ll I=1ll<<62,cs=1;
    for(;I;I>>=1)
    {
        cs=cs*cs%P;
        if(I&Y)cs=cs*X%P;
    }
    return cs;
}
int N,K;
ll PS1,PS2;
vector<int>V;
struct C{
int H1,H2;
int from;
C RG(C&X)
{
    return {((H1-X.H1*PS1)%p1+p1)%p1,((H2-X.H2*PS2)%p2+p2)%p2};
}
bool operator<(const C&X)const{return H1==X.H1?H2<X.H2:H1<X.H1;}
bool operator==(const C&X)const{return H1==X.H1&&H2==X.H2;}
};
vector<C>VC,TV,TTV;
void BH(int n)
{
    int i;
    TV.resize(n+1);
    for(i=0;i<n;i++)
        TV[i+1]={(TV[i].H1*n1+V[i])%p1,(TV[i].H2*n2+V[i])%p2};
}
int in()
{
    int M;
    cin>>M;
    V.resize(M);
    for(int&I:V)cin>>I;
    return M;
}
void getH()
{
    TTV.clear();
    for(int i=K;i<TV.size();i++)
    {
        TTV.push_back(TV[i].RG(TV[i-K]));
    }
}
void first()
{
    VC.clear();
    int L=in();
    BH(L);
    getH();
    VC.insert(VC.end(),TTV.begin(),TTV.end());
    sort(VC.begin(),VC.end());
    VC.resize(distance(VC.begin(),unique(VC.begin(),VC.end())) );
    for(auto&I:VC)I.from=(&I-&VC[0]);
}
void second()
{
    ext.reset();
    int L=in();
    BH(L);
    getH();
    for(auto&I:TTV)
    {
        if(I==*lower_bound(VC.begin(),VC.end(),I));
            ext[(*lower_bound(VC.begin(),VC.end(),I)).from]=1;
    }
    reverse(V.begin(), V.end());
    BH(L);
    getH();
    for(auto&I:TTV)
    {
        if(I==*lower_bound(VC.begin(),VC.end(),I));
            ext.set((*lower_bound(VC.begin(),VC.end(),I)).from);
    }
    int w=0;
    for(auto&I:VC)
    {
        if(ext[I.from])
            VC[w++]=I;
    }
    VC.resize(w);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>N>>K;
    PS1=PW(n1,K,p1),PS2=PW(n2,K,p2);
    first();
    int i;
    for(i=1;i<N;i++)
        second();
    printf("%s",VC.empty()?  "NO":"YES");
}

Compilation message

vaccine.cpp: In member function 'C C::RG(C&)':
vaccine.cpp:25:34: warning: narrowing conversion of '((((((ll)((C*)this)->C::H1) - (((ll)X.C::H1) * PS1)) % p1) + p1) % p1)' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
     return {((H1-X.H1*PS1)%p1+p1)%p1,((H2-X.H2*PS2)%p2+p2)%p2};
             ~~~~~~~~~~~~~~~~~~~~~^~~
vaccine.cpp:25:59: warning: narrowing conversion of '((((((ll)((C*)this)->C::H2) - (((ll)X.C::H2) * PS2)) % p2) + p2) % p2)' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
     return {((H1-X.H1*PS1)%p1+p1)%p1,((H2-X.H2*PS2)%p2+p2)%p2};
                                      ~~~~~~~~~~~~~~~~~~~~~^~~
vaccine.cpp: In function 'void BH(int)':
vaccine.cpp:36:36: warning: narrowing conversion of '(((((ll)TV.std::vector<C>::operator[](((std::vector<C>::size_type)i)).C::H1) * n1) + ((ll)V.std::vector<int>::operator[](((std::vector<int>::size_type)i)))) % p1)' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
         TV[i+1]={(TV[i].H1*n1+V[i])%p1,(TV[i].H2*n2+V[i])%p2};
                  ~~~~~~~~~~~~~~~~~~^~~
vaccine.cpp:36:58: warning: narrowing conversion of '(((((ll)TV.std::vector<C>::operator[](((std::vector<C>::size_type)i)).C::H2) * n2) + ((ll)V.std::vector<int>::operator[](((std::vector<int>::size_type)i)))) % p2)' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
         TV[i+1]={(TV[i].H1*n1+V[i])%p1,(TV[i].H2*n2+V[i])%p2};
                                        ~~~~~~~~~~~~~~~~~~^~~
vaccine.cpp: In function 'void getH()':
vaccine.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=K;i<TV.size();i++)
                 ~^~~~~~~~~~
vaccine.cpp: In function 'void second()':
vaccine.cpp:73:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(I==*lower_bound(VC.begin(),VC.end(),I));
         ^~
vaccine.cpp:74:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ext[(*lower_bound(VC.begin(),VC.end(),I)).from]=1;
             ^~~
vaccine.cpp:81:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(I==*lower_bound(VC.begin(),VC.end(),I));
         ^~
vaccine.cpp:82:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ext.set((*lower_bound(VC.begin(),VC.end(),I)).from);
             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Runtime error 4 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 772 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 828 KB Output is correct
2 Runtime error 3 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 852 KB Output is correct
2 Runtime error 6 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1044 KB Output is correct
2 Correct 28 ms 1336 KB Output is correct
3 Correct 42 ms 1828 KB Output is correct
4 Incorrect 19 ms 2028 KB Output isn't correct
5 Halted 0 ms 0 KB -