QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863696#8830. Breaking Badoperator_WA 0ms20052kbC++172.5kb2025-01-19 21:19:002025-01-19 21:19:07

Judging History

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

  • [2025-01-19 21:19:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:20052kb
  • [2025-01-19 21:19:00]
  • 提交

answer

//Date: 2025-01-19 20:32:02
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define P emplace_back
#define CLEAR(a,v) memset((a),(v),sizeof((a)))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
int n,a[1005][1005],x[1005],y[1005],f1[1005][1025][5],f2[1005][1025][5],f3[11][1025][1025][5],vis[5],res;
void MAIN() {
    cin>>n;rep(i,1,n) rep(j,1,n) a[i][j]=rd();
    rep(t,1,5) {
        int fl=0;rep(i,t*2,n) rep(j,t*2,n) if((a[2*t-1][2*t-1]+a[i][j])%5!=(a[2*t-1][j]+a[i][2*t-1])%5) 
            {rep(k,1,n) swap(a[i][k],a[2*t][k]),swap(a[k][j],a[k][2*t]);fl=1;break;}
        if(!fl) {
            t=t*2-1;
            rep(i,t,n) x[i]=a[t][i],y[i]=a[i][t]-a[t][t];
            rep(j,t,n) {res+=x[j];rep(i,1,n) a[i][j]-=x[j];}
            rep(i,t,n) {res+=y[i];rep(j,1,n) a[i][j]-=y[i];}
            // cerr<<t<<' '<<res<<endl;rep(i,1,n) rep(j,1,n) cerr<<a[i][j]<<" \n"[j==n];
            f1[t-1][0][0]=1,f2[t-1][0][0]=1,f3[0][0][0][0]=1;
            rep(j,t,n) rep(S,0,(1<<t-1)-1) rep(x,0,4) {
                f1[j][S][x]=f1[j-1][S][x];
                rep(i,1,t-1) if(S>>i-1&1) f1[j][S][x]|=f1[j-1][S^(1<<i-1)][(x-a[i][j]+5)%5];
            }
            rep(i,t,n) rep(S,0,(1<<t-1)-1) rep(x,0,4) {
                f2[i][S][x]=f2[i-1][S][x];
                rep(j,1,t-1) if(S>>j-1&1) f2[i][S][x]|=f2[i-1][S^(1<<j-1)][(x-a[i][j]+5)%5];
            }
            rep(i,1,t-1) rep(S,0,(1<<i)-1) rep(T,0,(1<<t-1)-1) rep(x,0,4) {
                if((S>>i-1&1)==0) f3[i][S][T][x]|=f3[i-1][S][T][x];
                else rep(j,1,t-1) if(T>>j-1&1) f3[i][S][T][x]|=f3[i-1][S^(1<<i-1)][T^(1<<j-1)][(x-a[i][j]+5)%5];
            }
            rep(S,0,(1<<t-1)-1) rep(x,0,4) if(f2[n][S][x]) rep(T,0,(1<<t-1)-1) rep(y,0,4) if(f1[n][T][y])
                rep(z,0,4) vis[(x+y+z)%5]|=f3[t-1][(1<<t-1)-1-S][(1<<t-1)-1-T][z];
            res%=5;rep(i,0,4) putchar(vis[(i-res+5)%5]?'Y':'N');return;
        }
    }
    puts("YYYYY");
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 13908kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

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

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

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

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: 17996kb

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: -100
Wrong Answer
time: 0ms
memory: 20052kb

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:

YYYYY

result:

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