Submission #19019917
Source Code Expand
Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------
int A,B,C,D;
const ll mo=998244353;
ll comb(ll N_, ll C_) {
const int NUM_=1400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
if (fact[0]==0) {
inv[1]=fact[0]=factr[0]=1;
for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
}
if(C_<0 || C_>N_) return 0;
return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}
ll modpow(ll a, ll n = mo-2) {
ll r=1;a%=mo;
while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
return r;
}
ll rr;
ll dp[4][11][11][11][11];
ll go(int cur,int A,int B,int C,int D) {
if(A+B+C+D==0) {
return cur==0;
}
if(dp[cur][A][B][C][D]>=0) return dp[cur][A][B][C][D];
ll ret=0;
if(cur==0) {
if(D) ret+=go(3,A,B,C,D-1);
if(A) ret+=go(1,A-1,B,C,D);
}
if(cur==1) {
if(A) ret+=go(0,A-1,B,C,D);
if(B) ret+=go(2,A,B-1,C,D);
}
if(cur==2) {
if(B) ret+=go(1,A,B-1,C,D);
if(C) ret+=go(3,A,B,C-1,D);
}
if(cur==3) {
if(C) ret+=go(2,A,B,C-1,D);
if(D) ret+=go(0,A,B,C,D-1);
}
return dp[cur][A][B][C][D]=ret%mo;
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>A>>B>>C>>D;
MINUS(dp);
//cout<<go(0,A,B,C,D)<<endl;
ll ret=0;
for(int L=0;L<=500000;L++) {
int X[4]={A-L,B-L,C-L,D-L};
FOR(i,4) {
if(X[i]<0) break;
if(X[i]%2) break;
X[i]/=2;
}
if(i<4) continue;
ll pat=comb(L+X[0]+X[3],L)*comb(X[0]+X[3],X[3])%mo*modpow(2,L)%mo;
/*
//cout<<L<<" "<<pat<<"!"<<ret<<endl;
// T->U
for(x=0;x<=X[1];x++) {
// V->U
for(y=0;y<=X[2];y++) {
ll pat2=hcomb(L+X[0],x)*hcomb(L+x,X[2]-y)%mo*hcomb(X[3],y)*hcomb(y,X[1]-x)%mo;
//ret+=pat*pat2%mo;
}
}
*/
ll pat2=hcomb(2*L+X[0]+X[3],X[1]+X[2])%mo;
ret+=pat*pat2%mo;
}
cout<<ret%mo<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
D - C4 |
User |
kmjp |
Language |
C++ (GCC 9.2.1) |
Score |
0 |
Code Size |
2711 Byte |
Status |
WA |
Exec Time |
107 ms |
Memory |
36912 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:68:8: warning: unused variable ‘j’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:68:10: warning: unused variable ‘k’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:68:12: warning: unused variable ‘l’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:68:14: warning: unused variable ‘r’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:68:16: warning: unused variable ‘x’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:68:18: warning: unused variable ‘y’ [-Wunused-variable]
68 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^
./Main.cpp:108:38: note: in expansion of macro ‘FOR’
108 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 1800 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt, example2.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, example0.txt, example1.txt, example2.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
WA |
107 ms |
36824 KB |
001.txt |
WA |
95 ms |
36720 KB |
002.txt |
WA |
95 ms |
36836 KB |
003.txt |
WA |
95 ms |
36836 KB |
004.txt |
WA |
95 ms |
36912 KB |
005.txt |
WA |
97 ms |
36776 KB |
006.txt |
WA |
96 ms |
36876 KB |
007.txt |
WA |
100 ms |
36764 KB |
008.txt |
WA |
97 ms |
36820 KB |
009.txt |
WA |
96 ms |
36880 KB |
010.txt |
WA |
98 ms |
36828 KB |
011.txt |
WA |
98 ms |
36836 KB |
012.txt |
WA |
95 ms |
36840 KB |
013.txt |
WA |
99 ms |
36824 KB |
014.txt |
WA |
100 ms |
36900 KB |
015.txt |
WA |
95 ms |
36876 KB |
016.txt |
WA |
96 ms |
36820 KB |
017.txt |
WA |
96 ms |
36880 KB |
018.txt |
WA |
93 ms |
36876 KB |
019.txt |
WA |
94 ms |
36772 KB |
020.txt |
WA |
77 ms |
36840 KB |
021.txt |
WA |
73 ms |
36876 KB |
022.txt |
WA |
72 ms |
36760 KB |
023.txt |
WA |
75 ms |
36764 KB |
024.txt |
WA |
72 ms |
36876 KB |
025.txt |
WA |
77 ms |
36864 KB |
026.txt |
WA |
73 ms |
36872 KB |
027.txt |
WA |
77 ms |
36848 KB |
028.txt |
WA |
73 ms |
36868 KB |
029.txt |
WA |
70 ms |
36720 KB |
030.txt |
WA |
78 ms |
36872 KB |
031.txt |
WA |
85 ms |
36836 KB |
032.txt |
WA |
73 ms |
36780 KB |
033.txt |
WA |
80 ms |
36764 KB |
034.txt |
WA |
82 ms |
36772 KB |
035.txt |
WA |
75 ms |
36796 KB |
036.txt |
WA |
78 ms |
36840 KB |
037.txt |
WA |
80 ms |
36764 KB |
038.txt |
WA |
75 ms |
36900 KB |
039.txt |
WA |
79 ms |
36872 KB |
040.txt |
WA |
98 ms |
36760 KB |
041.txt |
AC |
7 ms |
4036 KB |
example0.txt |
AC |
70 ms |
36776 KB |
example1.txt |
AC |
5 ms |
4032 KB |
example2.txt |
WA |
98 ms |
36828 KB |