QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74384#5442. Referee Without Redvme50Compile Error//C++142.6kb2023-01-31 23:06:482023-01-31 23:06:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-31 23:06:51]
  • 评测
  • [2023-01-31 23:06:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 1000005
#define M 3000005
#define LIM 10000005
#define MOD 998244353
#define pb push_back
#define gc() (P1==P2 && (P2=(P1=buf)+fread(buf,1,LIM,stdin),P1==P2)?EOF:*P1++)
char buf[LIM],*P1=buf,*P2=buf;
int T,n1,n2,m1,m2,tp1,tp2,ans,z[N],nxt[N],fa[N*2],a[M],inv[M],nw[M];
bool vs1[N],vs2[N];vector<int> vc1[N],vc2[N];
int rd()
{
    int res=0;char c=0;while(!isdigit(c)) c=gc();
    while(isdigit(c)) res=res*10+(c-48),c=gc();return res;
}
void init(int n)
{for(int i=1;i<=n;++i) inv[i]=i>1?1ll*inv[MOD%i]*(MOD-MOD/i)%MOD:1;}
int f(int x1,int x2) {return a[x1*n2+x2];}
int findRt(int u) {return u==fa[u]?u:fa[u]=findRt(fa[u]);}
bool merge(int u,int v)
{u=findRt(u);v=findRt(v);if(u==v) return 0;fa[u]=v;return 1;}
int slv1()
{
    for(int i=2,t=0;i<=z[0];++i)
    {while(t && z[i]!=z[t+1]) t=nxt[t];if(z[i]==z[t+1]) ++t;nxt[i]=t;}
    for(int i=nxt[z[0]];i;i=nxt[i])
        if(!(z[0]%(z[0]-i))) return z[0]-i;return z[0];
}
void slv()
{
    n1=rd();n2=rd();for(int i=0;i<n1*n2;++i) {a[i]=rd();if(n==18) putchar(a[i]+48);}
    if(n==18) putchar('\n');
    m1=n1-(!(n1&1));m2=n2-(!(n2&1));ans=1;
    for(int i=1;i<=tp1;++i) vc1[i].clear();
    for(int i=1;i<=tp2;++i) vc2[i].clear();tp1=tp2=0;
    for(int i=0;i<n1;++i) vs1[i]=0;for(int i=0;i<n2;++i) vs2[i]=0;
    for(int i=1;i<m1;++i) if(!vs1[i])
    {++tp1;for(int j=i;!vs1[j];j=(j*2)%m1) vs1[j]=1,vc1[tp1].pb(j);}
    for(int i=1;i<m2;++i) if(!vs2[i])
    {++tp2;for(int j=i;!vs2[j];j=(j*2)%m2) vs2[j]=1,vc2[tp2].pb(j);}
    for(int i=1;i<=tp2;++i)
    {z[0]=0;for(auto j:vc2[i]) z[++z[0]]=f(0,j);ans=1ll*ans*slv1()%MOD;}
    for(int i=1;i<=tp1;++i)
    {z[0]=0;for(auto j:vc1[i]) z[++z[0]]=f(j,0);ans=1ll*ans*slv1()%MOD;}
    if(!(n1&1)) for(int i=1;i<=tp2;++i)
    {z[0]=0;for(auto j:vc2[i]) z[++z[0]]=f(m1,j);ans=1ll*ans*slv1()%MOD;}
    if(!(n2&1)) for(int i=1;i<=tp1;++i)
    {z[0]=0;for(auto j:vc1[i]) z[++z[0]]=f(j,m2);ans=1ll*ans*slv1()%MOD;}
    for(int i=0;i<=tp1+tp2;++i) fa[i]=i;
    for(int i1=1,t,u,v,nw1;i1<=tp1;++i1) for(int i2=1;i2<=tp2;++i2)
    {
        bool fl=0;nw1=0;
        for(auto j1:vc1[i1]) for(auto j2:vc2[i2])
        {
            t=f(j1,j2);++nw1;++nw[t];fl|=(nw[t]>1);
            ans=1ll*ans*nw1%MOD*inv[nw[t]]%MOD;
        }
        if(nw1>1 && !fl)
        {
            u=vc1[i1].size()&1?0:tp1+i2;v=vc2[i2].size()&1?0:i1;
            if(!merge(u,v)) ans=1ll*ans*inv[2]%MOD;
        }for(auto j1:vc1[i1]) for(auto j2:vc2[i2]) --nw[f(j1,j2)];
    }printf("%d\n",ans);
}
int main() {init(3e6);T=rd();while(T--) slv();return 0;}

详细

answer.code: In function ‘void slv()’:
answer.code:32:60: error: ‘n’ was not declared in this scope
   32 |     n1=rd();n2=rd();for(int i=0;i<n1*n2;++i) {a[i]=rd();if(n==18) putchar(a[i]+48);}
      |                                                            ^
answer.code:33:8: error: ‘n’ was not declared in this scope
   33 |     if(n==18) putchar('\n');
      |        ^