QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#863510 | #8830. Breaking Bad | gyydp123_LIM | WA | 1ms | 5716kb | C++20 | 2.4kb | 2025-01-19 18:24:45 | 2025-01-19 18:24:46 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1005;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')
x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
int n,a[N][N],x[N],y[N],f[1<<10],g[1<<10],h[1<<10],ans;
int b[N][N],pn;
int calc(int x,int y){return ((x<<y)|(x>>5-y))&31;}
signed LJY(){
n=read();For(i,1,n) For(j,1,n) a[i][j]=read();
For(d,1,5){
bool flg=0;
For(j,2*d,n) For(k,2*d,n)
if((a[2*d-1][2*d-1]+a[j][k])%5!=(a[j][2*d-1]+a[2*d-1][k])%5){
swap(a[2*d],a[j]);flg=1;
For(t,1,n) swap(a[t][2*d],a[t][k]);break;
}if(flg&&2*d<=n) continue;
d=2*(d-1);int sum=0;
For(j,d+1,n){
x[j]=a[j][d+1];sum=(sum+x[j])%5;
For(i,1,n) a[j][i]=(a[j][i]-x[j]+5)%5;
}For(j,d+1,n){
y[j]=(a[d+1][j]-a[d+1][d+1]+5)%5;sum=(sum+y[j])%5;
For(i,1,n) a[i][j]=(a[i][j]-y[j]+5)%5;
}f[0]=g[0]=1;
// For(i,1,n){For(j,1,n) debug("%d ",a[i][j]);debug("\n");}
For(i,d+1,n) ForDown(j,(1<<d)-1,0) For(k,0,d-1) if((j>>k)&1)
f[j]|=calc(f[j^(1<<k)],a[k+1][i]),g[j]|=calc(g[j^(1<<k)],a[i][k+1]);
For(S,0,(1<<d)-1) if(f[S]) For(T,0,(1<<d)-1)
if(g[T]&&__builtin_popcount(S)==__builtin_popcount(T)){pn=0;
// Debug("%d %d\n",S,T);
For(i,0,d-1) if(!(S&(1<<i))){pn++;int tmp=0;
For(j,0,d-1) if(!(T&(1<<j))) b[pn][++tmp]=a[i+1][j+1];}
// For(i,1,pn){For(j,1,pn) debug("%d ",b[i][j]);debug("\n");}
For(i,0,(1<<pn)-1) h[i]=0;h[0]=1;
For(i,1,pn) For(j,0,(1<<pn)-1) if(__builtin_popcount(j)==i)
For(k,0,pn-1) if(j&(1<<k)) h[j]|=calc(h[j^(1<<k)],b[i][k+1]);
int res=h[(1<<pn)-1],ret=0;
For(i,0,4) if(f[S]&(1<<i)) ret|=calc(res,i);
For(i,0,4) if(g[S]&(1<<i)) ans|=calc(ret,i);
}ans=calc(ans,sum);
For(i,0,4) if(ans&(1<<i)) putchar('Y');else putchar('N');
return 0;
}puts("YYYYY");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5712kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5716kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 0ms
memory: 5712kb
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: 5708kb
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: 5712kb
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:
NYYNY
result:
wrong answer 1st words differ - expected: 'NYNNY', found: 'NYYNY'