QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100149#4923. 整数lingchenCompile Error//C++141.8kb2023-04-24 20:23:302023-04-24 20:23:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-24 20:23:32]
  • 评测
  • [2023-04-24 20:23:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll p = 998244353;
const ll inv2 = 499122177;

int n;
int c[2100],t[2100];
ll f[2100],a[4100];
bitset<4010> e[4100],vis;

void clear(int n)
{
    memset(t, 0, sizeof(t));
    for(int i=1; i<=n*2; i++) e[i].reset();
}
ll qpow(ll a, ll b, ll p)
{
    ll ans=1;
    for(; b; b>>=1,(a*=a)%=p)
    if(b&1) (ans*=a)%=p;
    return ans;
}
ll solve()
{
    int x=0,y=0;

    for(int i=1; i<=n*2; i++) if(vis[i]) x=i;
    if(!x) return 1;
    for(int i=1; i<=n*2; i++) if(e[x][i]&&vis[i]) y=i;
    if(!y)
    {
        vis[x]=0;
        return (a[x]+1)*solve()%p;
    }

    vis[x]=vis[y]=0;
    bitset<4010> b[4];
    for(int i=0; i<2; i++)
    for(int j=0; j<2; j++)
    b[i*2+j]=(i ? ~e[x] : e[x])&(j ? ~e[y] : e[y])&vis;

    for(int i=0; i<3; i++)
    for(int k=1; k<=2*n; k++)
    if(b[i][k])
    for(int j=0; j<3; j++)
    if(i!=j)
    e[k]^=b[j];

    int fg=(a[x]==-1)*2+(a[y]==-1);
    for(int i=0; i<3; i++)
    if(i==fg||fg==3)
    for(int k=1; k<=n*2; k++)
    if(b[i][k])
    a[k]*=-1;

    return 2*(fg==3 ? p-1 : 1)*solve()%p;
}
void work()
{
    ll ans1=1,ans2;
    cin>>n; clear(n);
    for(int i=1; i<=n; i++)
    scanf("%d", &c[i]), ++t[c[i]];

    for(int i=1; i<=n; i++)
    {
        e[i][c[i]+n]=e[c[i]+n][i]=1;
        vis[i]=vis[i+n]=1;
        a[i]=a[i+n]=1;
    }
    for(int i=1; i<=n; i++)
    for(int j=i+1; j<=n; j++)
    if(c[i]>c[j])
    e[i][j]=e[j][i]=1;

    for(int i=1; i<=n; i++) ans1=ans1*f[t[i]]%p;
    ans2=solve()*qpow(inv2, n, p)%p;
    cout<<(ans1+ans2)*inv2%p<<"\n";
}
int main()
{
    int t;
    cin>>t;
    f[0]=f[1]=1;
    for(int i=2; i<=2000; i++) f[i]=(f[i-1]+(i-1)*f[i-2])%p;
    while(t-->0) work();
    return 0;
}

Details

implementer.cpp: In function ‘void integer_grader_F0F01B59EA9BF23E::generateToken()’:
implementer.cpp:19:57: warning: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>::result_type’ {aka ‘long unsigned int’} [-Wformat=]
   19 |                 for(int i = 1; i <= 40; i++) printf("%llX", (rng() & 15));
      |                                                      ~~~^   ~~~~~~~~~~~~
      |                                                         |          |
      |                                                         |          std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>::result_type {aka long unsigned int}
      |                                                         long long unsigned int
      |                                                      %lX
implementer.cpp: In function ‘void integer_grader_F0F01B59EA9BF23E::main()’:
implementer.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |                 scanf("%d", &n);
      |                 ~~~~~^~~~~~~~~~
implementer.cpp:49:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |                         scanf("%d", p + i);
      |                         ~~~~~^~~~~~~~~~~~~
answer.code: In function ‘void work()’:
answer.code:65:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |     scanf("%d", &c[i]), ++t[c[i]];
      |     ~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccXmCoB5.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/cchAD5B7.o:implementer.cpp:(.text.startup+0xb0): first defined here
/usr/bin/ld: /tmp/cchAD5B7.o: in function `integer_grader_F0F01B59EA9BF23E::main()':
implementer.cpp:(.text.startup+0x6d): undefined reference to `findPermutation(int)'
collect2: error: ld returned 1 exit status