垃圾考试浪费时间
T1:
不说是随机数据做
每次暴力很显然
每次考虑一次修改对当前根的影响,暴力跳即可
心情太差没写代码
T2:
以为分治消元跑不过去就没写
不过只消有值得位置就可以跑的很快
#include<bits/stdc++.h>
using namespace std;
#define re register
#define cs const
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
static char ibuf[RLEN],*ib,*ob;
(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return ib==ob?EOF:*ib++;
}
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
cs int mod=998244353;
inline int add(int a,int b){a+=b-mod;return a+(a>>31&mod);}
inline int dec(int a,int b){a-=b;return a+(a>>31&mod);}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline void Add(int &a,int b){a+=b-mod,a+=a>>31&mod;}
inline void Dec(int &a,int b){a-=b,a+=a>>31&mod;}
inline void Mul(int &a,int b){a=1ll*a*b%mod;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
cs int N=305;
int a[11][N][N];
typedef int ar[N];
typedef ar arr[N];
int n,m,in[N],ans[N],pos[N],cnt;
vector<int> e[N];
inline void solve(int l,int r,int dep){
auto f=a[dep],pre=a[dep-1];
// ar *ttt=f[dep];
if(l==r){
ans[l]=mul(pre[1][n+1],Inv(pre[1][1]));
return;
}
int mid=(l+r)/2;
for(int i=1;i<=n;i++)
for(int j=1;j<=n+1;j++)f[i][j]=pre[i][j];
for(int i=l;i<=mid;i++){
int iv=Inv(f[i][i]);cnt=0;
for(int j=1;j<=n+1;j++)if(f[i][j])pos[++cnt]=j;
for(int j=1;j<=n;j++)if(j!=i&&f[j][i]){
int mt=mul(f[j][i],iv);
for(int k=1;k<=cnt;k++)
Dec(f[j][pos[k]],mul(mt,f[i][pos[k]]));
}
}
solve(mid+1,r,dep+1);
for(int i=1;i<=n;i++)
for(int j=1;j<=n+1;j++)f[i][j]=pre[i][j];
for(int i=mid+1;i<=r;i++){
int iv=Inv(f[i][i]);cnt=0;
for(int j=1;j<=n+1;j++)if(f[i][j])pos[++cnt]=j;
for(int j=1;j<=n;j++)if(j!=i&&f[j][i]){
int mt=mul(f[j][i],iv);
for(int k=1;k<=cnt;k++)
Dec(f[j][pos[k]],mul(mt,f[i][pos[k]]));
}
}
solve(l,mid,dep+1);
}
int main(){
#ifdef Stargazer
freopen("lx.in","r",stdin);
freopen("my.out","w",stdout);
#endif
n=read(),m=read();
for(int i=1;i<=m;i++){
int u=read(),v=read();
in[u]++,Dec(a[0][u][v],1),Add(a[0][u][n+1],1);
}
for(int i=1;i<=n;i++)Add(a[0][i][i],in[i]);
solve(2,n,1);
for(int i=2;i<=n;i++)cout<<ans[i]<<'
';
}
T3:
暴力模拟交换即可
也不想写
考试体验极差,告辞