QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#459591#8830. Breaking Baducup-team1231#WA 919ms22400kbC++143.3kb2024-06-30 08:59:032024-06-30 09:00:38

Judging History

你现在查看的是最新测评结果

  • [2024-06-30 09:00:38]
  • 评测
  • 测评结果:WA
  • 用时:919ms
  • 内存:22400kb
  • [2024-06-30 08:59:03]
  • 提交

answer

#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define SZ 666666
#define pb push_back
#define fi first
#define se second
#define mp make_pair
const int MOD=969999931;
const int omega=18844598;
int n,a[1095][1095],w[1095][1095];
ll v[1095][1095];
ll qp(ll a,ll b) {
    ll x=1; a%=MOD;
    while(b) {
        if(b&1) x=x*a%MOD;
        a=a*a%MOD; b>>=1;
    }
    return x;
}
ll ev(ll s) {
    // cerr<<"+\n";
    // calc det mod (x-s)
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j) {
            ll x=1;
            for(int ss=a[i][j];ss;--ss)
                x=x*s%MOD;
            x=(x%MOD+MOD)%MOD;
            v[i][j]=x*w[i][j]%MOD;
        }
    // cerr<<"+AA\n";
    ll r=1;
    for(int i=0;i<n;++i) {
        int j=i;
        while(j<n&&v[j][i]%MOD==0) ++j;
        if(j>=n) return 0;
        if(i!=j) {
            r=MOD-r;
            for(int s=0;s<n;++s)
                swap(v[i][s],v[j][s]);
        }
        for(int s=0;s<n;++s) v[i][s]%=MOD;
        r=r*v[i][i]%MOD;
        if(r==0) return 0;
        ull iv=qp(v[i][i],MOD-2);
        for(int j=i+1;j<n;++j) {
            unsigned vv=MOD-v[j][i]%MOD*iv%MOD;
            if(vv)
            for(int k=i+1;k<n;k+=8) {
                v[j][k]+=(ull)vv*v[i][k];
                v[j][k+1]+=(ull)vv*v[i][k+1];
                v[j][k+2]+=(ull)vv*v[i][k+2];
                v[j][k+3]+=(ull)vv*v[i][k+3];
                v[j][k+4]+=(ull)vv*v[i][k+4];
                v[j][k+5]+=(ull)vv*v[i][k+5];
                v[j][k+6]+=(ull)vv*v[i][k+6];
                v[j][k+7]+=(ull)vv*v[i][k+7];
            }
            if(i%16==0) {
            for(int k=i+1;k<n;++k) v[j][k]%=MOD;
            }
        }
    }
    // cerr<<"+SS\n";
    return (r%MOD+MOD)%MOD;
}
ll ss[5];
ll PP[66],FF[66],QQ[66];
ll eval(ll*a,ll v) {
    ll x=0;
    for(int i=5;i>=0;--i)
        x=(x*v+a[i])%MOD;
    return x;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
   cin>>n;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j) {
            // a[i][j]=2;
           cin>>a[i][j];
            w[i][j]=rand()%MOD;
        }
    PP[0]=1;
    ll o=1;
    for(int i=0;i<5;++i) {
        ss[i]=ev(o);
        ll Fe=eval(FF,o),Pe=eval(PP,o);
        ll sth=(ss[i]-Fe)*qp(Pe,MOD-2)%MOD;
        // cerr<<Fe<<"++"<<Pe<<"what"<<sth<<"++\n";
        // FF += PP * sth, PP *= x-o
        for(int j=0;j<=5;++j)
            FF[j]=(FF[j]+PP[j]*sth)%MOD;
        for(int j=0;j<=5;++j)
            QQ[j]=PP[j]*(-o)%MOD;
        for(int j=0;j<=5;++j)
            (QQ[j+1]+=PP[j])%=MOD;
        for(int j=0;j<=5;++j) PP[j]=QQ[j];
        o=o*omega%MOD;
        // cout<<ss[i]<<"++\n";
        // for(int j=0;j<=5;++j)
        //     cout<<FF[j]<<",";
        // cout<<"fff\n";
        // for(int j=0;j<=5;++j)
        //     cout<<QQ[j]<<",";
        // cout<<"xxx\n";
    }
        for(int j=0;j<5;++j) printf("%c",(FF[j]%MOD)?'Y':'N');
        printf("\n");
    cerr<<clock()*1./CLOCKS_PER_SEC<<"\n";
}
/*
x^{a[i][j]}

x^5-1=(x-1)(x-o)(x-o^2)(x-o^3)(x-o^4)

FFF mod P
?? mod (x-o)
FFF+something*P == ss[...] so that it equals to 0 when x=o

0 mod 1
xxx mod (x-o)

*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 8120kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 0ms
memory: 8172kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: 0
Accepted
time: 0ms
memory: 8184kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #4:

score: 0
Accepted
time: 0ms
memory: 8180kb

input:

4
0 0 0 1
0 1 0 1
1 0 0 0
0 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #5:

score: 0
Accepted
time: 0ms
memory: 10224kb

input:

10
1 4 2 0 0 2 0 1 3 3
0 3 1 4 4 1 4 0 2 2
1 4 2 0 0 2 0 1 0 3
0 3 1 4 4 1 4 0 2 2
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
1 4 2 0 0 2 0 1 3 3
3 1 4 2 2 4 2 3 0 0

output:

NYNNY

result:

ok "NYNNY"

Test #6:

score: 0
Accepted
time: 0ms
memory: 8152kb

input:

10
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
3 3 3 0 2 3 0 3 2 4
4 4 4 1 3 4 1 4 3 0
2 2 2 4 1 2 4 2 1 3
2 2 2 4 1 3 4 2 1 3
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
2 2 2 4 1 2 4 2 1 3
4 4 4 1 3 4 1 1 3 0

output:

YYYNY

result:

ok "YYYNY"

Test #7:

score: 0
Accepted
time: 0ms
memory: 8208kb

input:

10
1 2 0 4 2 3 4 0 2 3
0 1 4 3 1 2 3 4 1 2
4 0 3 2 0 1 2 3 0 1
1 2 0 4 2 3 4 0 2 3
3 4 2 1 4 0 1 2 4 0
0 1 4 3 1 2 3 4 1 2
2 3 1 0 3 4 0 1 3 4
3 1 1 1 4 0 1 2 4 0
1 2 0 4 2 3 4 0 2 3
1 3 0 4 2 3 4 0 2 3

output:

NYYYY

result:

ok "NYYYY"

Test #8:

score: 0
Accepted
time: 0ms
memory: 8204kb

input:

10
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
2 3 4 2 1 1 4 3 4 1
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4

output:

NYNNN

result:

ok "NYNNN"

Test #9:

score: 0
Accepted
time: 0ms
memory: 10184kb

input:

10
4 1 3 1 2 0 3 2 4 4
0 2 4 2 3 1 4 3 0 0
1 1 1 1 2 0 3 2 4 1
2 4 1 4 0 3 1 0 2 2
1 3 0 3 4 2 0 4 1 1
2 4 1 4 0 3 1 0 2 2
2 4 1 4 0 3 1 0 2 2
0 2 4 2 3 1 4 3 0 0
3 0 2 1 1 4 2 1 3 3
4 1 3 1 2 0 3 2 4 4

output:

YYYYY

result:

ok "YYYYY"

Test #10:

score: 0
Accepted
time: 1ms
memory: 8156kb

input:

10
1 2 0 2 4 2 3 1 2 1
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
0 1 4 1 3 1 2 0 1 0

output:

NNNYN

result:

ok "NNNYN"

Test #11:

score: 0
Accepted
time: 1ms
memory: 8208kb

input:

10
1 4 1 2 1 3 3 2 1 2
0 3 0 1 0 2 2 1 0 1
0 4 0 3 0 2 2 1 0 1
1 4 1 2 1 3 3 2 1 2
4 2 4 0 4 1 1 0 4 0
1 1 1 4 1 0 3 2 1 2
0 0 0 1 0 2 2 1 0 1
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3

output:

YYYYY

result:

ok "YYYYY"

Test #12:

score: 0
Accepted
time: 1ms
memory: 8204kb

input:

10
1 2 0 1 4 0 1 2 2 2
1 2 0 1 4 3 1 2 2 2
0 1 4 0 3 1 0 1 1 1
1 2 0 1 4 3 1 2 2 2
3 4 2 3 1 4 3 4 4 4
0 1 4 0 3 1 0 1 1 1
4 0 3 4 2 0 4 0 0 0
3 4 2 3 1 4 3 4 4 4
4 0 3 4 2 0 4 0 0 0
0 1 4 0 3 1 0 1 1 1

output:

YNYNY

result:

ok "YNYNY"

Test #13:

score: 0
Accepted
time: 0ms
memory: 10244kb

input:

10
1 3 0 0 2 1 3 4 3 3
3 3 0 0 4 1 3 4 3 3
1 1 3 3 2 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
4 1 3 3 0 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
0 2 4 4 1 0 2 3 2 2
3 0 2 2 4 3 0 1 0 0
3 0 2 2 4 3 0 1 0 0
4 2 4 4 1 0 2 3 2 2

output:

YYYNY

result:

ok "YYYNY"

Test #14:

score: 0
Accepted
time: 0ms
memory: 10036kb

input:

10
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
1 4 2 0 2 4 4 4 3 0
3 3 4 2 4 1 1 1 0 2
3 1 4 2 4 1 1 1 0 2
4 2 0 3 0 2 2 2 1 3
3 1 4 2 4 1 1 1 0 2
1 4 2 0 2 4 4 4 3 0

output:

YNYNN

result:

ok "YNYNN"

Test #15:

score: 0
Accepted
time: 918ms
memory: 22400kb

input:

1000
3 4 1 2 4 1 0 3 0 4 1 4 3 1 4 4 1 0 1 2 3 1 0 1 3 4 4 0 3 0 3 2 2 1 0 4 1 3 3 0 3 1 3 2 2 0 3 3 2 2 3 0 4 2 1 2 1 2 1 4 2 4 1 4 2 4 3 2 0 3 0 4 2 1 2 3 3 0 2 0 3 3 1 1 0 3 4 3 2 0 4 0 3 4 4 2 3 4 2 3 4 2 1 3 2 2 4 1 0 2 2 4 0 1 2 0 4 1 3 2 3 2 2 2 1 4 4 4 2 0 0 4 4 1 3 4 0 2 2 3 1 1 3 2 3 2 3 0...

output:

NNNYN

result:

ok "NNNYN"

Test #16:

score: -100
Wrong Answer
time: 919ms
memory: 22292kb

input:

1000
2 3 0 1 0 0 0 1 1 4 1 4 2 3 0 3 4 2 3 2 4 2 1 1 1 1 0 0 3 3 2 0 2 2 2 4 3 0 3 3 3 0 1 3 0 2 0 1 0 0 0 3 1 4 3 1 4 0 3 4 4 1 3 3 4 0 1 4 2 3 0 1 0 0 2 3 1 4 0 0 2 1 2 3 3 4 4 3 3 2 0 0 4 3 2 3 3 2 4 0 2 2 3 0 3 2 4 1 0 2 4 2 4 1 2 1 3 0 3 3 0 1 1 0 2 3 0 2 4 1 4 3 4 1 2 2 2 4 0 1 3 3 0 0 1 3 2 4...

output:

YYYYY

result:

wrong answer 1st words differ - expected: 'NYYYY', found: 'YYYYY'