QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359064#7612. Matrix InversehaiCompile Error//C++143.6kb2024-03-20 11:51:162024-03-20 11:51:16

Judging History

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

  • [2024-03-20 11:51:16]
  • 评测
  • [2024-03-20 11:51:16]
  • 提交

answer

# include <bits/stdc++.h>
# include <atcoder/modint>
# define N 2005
# define mod 1000000007
using namespace std;
using mint=atcoder::modint1000000007;
int n;
mint a[N][N],b[N][N],c[N][N];
mt19937 D(time(0));
mint Rnd()
{
    uniform_int_distribution<int> R(0,1000000006);
    return R(D);
}
mint tmp[N],tmp2[N],tmp3[N];
bool mark1[N],mark2[N];
int num1[N],tot1,num2[N],tot2;
mint f[150][150];
mint ans[150];
int tot;
vector<tuple<int,int,int>> res;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            int x;
            scanf("%d",&x);
            a[i][j]=x;
        }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            int x;
            scanf("%d",&x);
            c[i][j]=x;
        }
    for(int t=1;t<=5;t++)
    {
        for(int i=1;i<=n;i++)
            tmp[i]=Rnd();
        memset(tmp2,0,sizeof tmp2);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                tmp2[j]+=tmp[i]*a[i][j];
        memset(tmp3,0,sizeof tmp3);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                tmp3[j]+=tmp2[i]*c[i][j];
        for(int i=1;i<=n;i++)
            if(tmp3[i]!=tmp[i])
                mark2[i]=1;
    }
    for(int t=1;t<=5;t++)
    {
        for(int i=1;i<=n;i++)
            tmp[i]=Rnd();
        memset(tmp2,0,sizeof tmp2);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                tmp2[i]+=tmp[j]*c[i][j];
        memset(tmp3,0,sizeof tmp3);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                tmp3[i]+=tmp2[j]*a[i][j];
        for(int i=1;i<=n;i++)
            if(tmp3[i]!=tmp[i])
                mark1[i]=1;
    }
    for(int i=1;i<=n;i++)
        if(mark1[i])
            num1[++tot1]=i;
    for(int i=1;i<=n;i++)
        if(mark2[i])
            num2[++tot2]=i;
    if(tot1*tot2>12)
    {
        cout<<"FUCK"<<' '<<tot1<<' '<<tot2<<endl;
        return 0;
    }
    tot=0;
    res.clear();
    for(int t=1;t<=tot1;t++)
    {
        for(int i=1;i<=n;i++)
            tmp[i]=Rnd();
        memset(tmp2,0,sizeof tmp2);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                tmp2[j]+=tmp[i]*a[i][j];
        for(int i=1;i<=tot2;i++)
        {
            tot++;
            f[tot][tot1*tot2+1]=tmp[num2[i]];
            for(int j=1;j<=n;j++)
                if(!mark1[j])
                    f[tot][tot1*tot2+1]-=tmp2[j]*c[j][num2[i]];
            for(int j=1;j<=tot1;j++)
                f[tot][(j-1)*tot2+i]+=tmp2[num1[j]];
        }
    }
    int m=tot1*tot2;
    for(int i=1;i<=m;i++)
    {
        if(f[i][i].val()==0)
        {
            for(int j=i+1;j<=m;j++)
                if(f[j][i].val())
                {
                    swap(f[j],f[i]);
                    break;
                }
        }
        auto p=f[i][i];
        for(int j=i;j<=m+1;j++)
            f[i][j]/=p;
        for(int j=i+1;j<=m;j++)
        {
            for(int k=i+1;k<=m+1;k++)
                f[j][k]-=f[i][k]*f[j][i];
            f[j][i]=0;
        }
    }
    for(int i=m;i>=1;i--)
    {
        ans[i]=f[i][m+1];
        for(int j=i+1;j<=m;j++)
            ans[i]-=f[i][j]*ans[j];
    }
    memcpy(b,c,sizeof b);
    for(int i=1;i<=tot1;i++)
        for(int j=1;j<=tot2;j++)
            if(ans[(i-1)*tot2+j]!=b[num1[i]][num2[j]])
                res.push_back({num1[i],num2[j],ans[(i-1)*tot2+j].val()}),b[num1[i]][num2[j]]=ans[(i-1)*tot2+j];
    cout<<res.size()<<endl;
    for(auto [i,j,num]:res)
        printf("%d %d %d\n",i,j,num);
    return 0;
}

Details

answer.code:2:11: fatal error: atcoder/modint: No such file or directory
    2 | # include <atcoder/modint>
      |           ^~~~~~~~~~~~~~~~
compilation terminated.