Submission #1050164

# Submission time Handle Problem Language Result Execution time Memory
1050164 2024-08-09T07:47:55 Z modwwe NoM (RMI21_nom) C++17
100 / 100
48 ms 23124 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const ll inf=1e18;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    ll a;
    ll b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

ll n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;

main()
{
#ifndef ONLINE_JUDGE
//  fin(task),fou(task);
#endif
     NHP
    /// cin>>s1;
    //  modwwe
    phongbeo();
}
int dp[2002][2001];
int fac[2001];
int c[2001];
int invf[4001];
int ipow(int x, int p)
{
    int  ret = 1, piv = x;
    while(p)
    {
        if(p&1) ret *= piv;
        piv *= piv;
        ret %= mod2;
        piv %= mod2;
        p >>= 1;
    }
    return ret;
}
int add(int x,int y)
{
    if(x+y>=mod2) x-=mod2;
     return x+y;
}
int C(int x,int y)
{
     return fac[x]*(invf[x-y]*invf[y]%mod2)%mod2;
}
void phongbeo()
{
     cin>>n>>m;
      for(int i=1;i<=n*2;i++)
         c[i%m+1]++;
         fac[0]=1;
         invf[0]=1;
         for(int i=1;i<=n;i++)
            fac[i]=(fac[i-1]*i)%mod2,
            invf[i]=ipow(fac[i],mod2-2);
         dp[1][0]=1;
         s7=1;
         for(int i=1;i<=n;i++)
            s7=(s7*2)%mod2;
 for(int i=1;i<=m;i++)
 {
     for(int f=0;f<=c[i];f++)
        {
             s2=c[i]-f;
  s6=n*2-s5;
            for(int j=s2;j<=n;j++){
                 if(dp[i][j]&&(s6-j)/2>=f&&j-s2+f<=n)
                 dp[i+1][j-s2+f]=add(dp[i+1][j-s2+f],(dp[i][j]*C(j,s2)%mod2)*C((s6-j)/2,f)%mod2);
               if(j-s2+f>n) break;
                 }
        }
        s5+=c[i];
        s7=(s7*fac[c[i]])%mod2;
 }

  cout<<(s7*dp[m+1][0])%mod2;
}

Compilation message

Main.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main()
      | ^~~~
Main.cpp: In function 'void phongbeo()':
Main.cpp:90:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   90 |       for(int i=1;i<=n*2;i++)
      |       ^~~
Main.cpp:92:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   92 |          fac[0]=1;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 1628 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1628 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 1628 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1628 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 4 ms 2596 KB Output is correct
30 Correct 5 ms 4188 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 2652 KB Output is correct
33 Correct 7 ms 4700 KB Output is correct
34 Correct 9 ms 7160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 1628 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1628 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 4 ms 2596 KB Output is correct
30 Correct 5 ms 4188 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 2652 KB Output is correct
33 Correct 7 ms 4700 KB Output is correct
34 Correct 9 ms 7160 KB Output is correct
35 Correct 14 ms 604 KB Output is correct
36 Correct 36 ms 18940 KB Output is correct
37 Correct 13 ms 612 KB Output is correct
38 Correct 24 ms 8960 KB Output is correct
39 Correct 28 ms 15960 KB Output is correct
40 Correct 48 ms 23124 KB Output is correct