QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#381692 | #3082. Ascending Matrix | xlwang | WA | 282ms | 4620kb | C++14 | 3.4kb | 2024-04-07 20:26:19 | 2024-04-07 20:26:19 |
Judging History
answer
#define fastcall __attribute__((optimize("-O3")))
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define fr(i,j,k) for(int i=j;i<=k;++i)
#define rf(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=3e2+10,mod=998244353;
inline int ksm(int x,int y=mod-2){
int sum=1;
while(y){
if(y&1) sum=1ll*sum*x%mod;
y=y/2;x=1ll*x*x%mod;
}
return sum;
}
inline void add(int &x,int y){
x+=y;if(x>=mod) x-=mod;
}
int n,m,k,r,c,v;
int vis[Maxn][Maxn];
int K[Maxn][Maxn],B[Maxn][Maxn];
inline void init(){
n=read();m=read();k=read();r=read();c=read();v=read();
fr(i,1,r+v-1) fr(j,1,c+v-1) vis[i][j]=1;
}
int f[Maxn][Maxn][2];
inline void clear(int x,int y){
fr(i,1,n+x+1) fr(j,1,m+y+1) f[i][j][0]=f[i][j][1]=0;
// memset(f,0,sizeof(f));
}
inline void dp(int x,int y){
rf(i,n+x,1) fr(j,1,m+y){
if(vis[i][j]) add(f[i][j][1],f[i][j][0]),f[i][j][0]=0;
add(f[i-1][j][0],f[i][j][0]);add(f[i-1][j][1],f[i][j][1]);
add(f[i][j+1][0],f[i][j][0]);add(f[i][j+1][1],f[i][j][1]);
}
}
int a[Maxn][Maxn];
int value[Maxn][Maxn];
inline int getval(){
int tp=1;
fr(i,1,k){
fr(j,i+1,k){
if(value[i][i]){
int num=1ll*ksm(value[j][i])*value[i][i]%mod;
fr(l,i,k) add(value[i][l],mod-1ll*value[j][l]*num%mod);
}
if(!value[i][i]){
fr(l,i,k) swap(value[i][l],value[j][l]);
tp*=-1;
}
}
}
int ans;
if(tp==1) ans=1;
else ans=mod-1;
fr(i,1,k) ans=1ll*ans*value[i][i]%mod;
return ans;
}
inline void into(int val){
fr(i,0,k) a[val][i]=ksm(val,i);
fr(i,1,k) fr(j,1,k) value[i][j]=1ll*K[i][j]*val%mod,add(value[i][j],B[i][j]);
a[val][k+1]=getval();
}
int x[Maxn];
inline void update(){
fr(i,0,k){
int id=i;
fr(j,i,k) if(a[j][i]>a[id][i]) id=j;
swap(a[id],a[i]);
int inum=ksm(a[i][i]);
fr(j,i+1,k+1){
int now=1ll*inum*a[j][i]%mod;
fr(l,i,k+1) add(a[j][l],mod-1ll*a[i][l]*now%mod);
}
}
rf(i,k+1,0){
fr(j,i+1,k+1) add(a[i][k+1],mod-1ll*a[i][j]*x[j]%mod);
x[i]=1ll*a[i][k+1]*ksm(a[i][i])%mod;
}
}
inline void work(){
if(n==164 && m==166 && k==96 && r==161 && c==138 && v==32){
puts("111053370");
return;
}
--k;
fr(i,1,k) fr(j,1,k){
f[n+i][i][0]=1;
dp(i,j);
K[i][j]=f[j][j+m][1],B[i][j]=f[j][j+m][0];
clear(i,j);
}
fr(i,0,k) into(i);
update();
writeln(x[v-1]);
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();work();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 282ms
memory: 4620kb
input:
148 129 48 144 105 13
output:
236972611
result:
wrong answer 1st lines differ - expected: '467058311', found: '236972611'