QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#316449 | #8173. T Tile Placement Counting | ucup-team191# | WA | 1ms | 3880kb | C++23 | 3.9kb | 2024-01-27 20:53:25 | 2024-01-27 20:53:25 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
#define sz(a) (int)(a).size()
#define rep(i, a, b) for(int i = a;i < (b); ++i)
const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
const ll mod=998244353;
ll modpow(ll b,ll e)
{
ll ans=1;
for (;e;b=b*b%mod,e/=2) if (e&1) ans=ans*b%mod;
return ans;
}
typedef vector<ll> Poly;
ll linearRec(Poly S,Poly tr,ll k)
{
int n=sz(tr);
auto combine = [&](Poly a,Poly b) {
Poly res(n*2+1);
rep(i,0,n+1) rep(j,0,n+1) res[i+j]=(res[i+j]+a[i]*b[j])%mod;
for (int i=2*n;i>n;--i) rep(j,0,n) res[i-1-j]=(res[i-1-j]+res[i]*tr[j])%mod;
res.resize(n+1);
return res;
};
Poly pol(n+1),e(pol);
pol[0]=e[1]=1;
for (++k;k;k/=2) {
if (k%2) pol=combine(pol,e);
e=combine(e,e);
}
ll res=0;
rep(i,0,n) res=(res+pol[i+1]*S[i])%mod;
return res;
}
int n;
ll m;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
if (n%4 || m%4)
{
cout<<0<<en;
exit(0);
}
vl s,tr;
if (n==4)
{
s={3};
tr={2};
}
if (n==8)
{
s={16, 998244326};
tr={6, 84};
}
if (n==12)
{
s={87, 998242913, 6183, 998237792};
tr={18, 1182, 78696, 5253822};
}
if (n==16)
{
s={528, 998161454, 5739200, 794169011, 985606941, 210679522, 777831988, 126141317, 5201730, 220846254};
tr={54, 16644, 5253822, 669847183, 386282067, 157705668, 324635103, 664730403, 590548248, 718440881};
}
if (n==20)
{
s={3227, 994412993, 393855742, 566425941, 877370465, 425354021, 207853870, 660679731, 689997464, 215850254, 31658021, 37873191, 178397082, 307645285, 102470226, 259694005, 147391269, 47767918, 306983260, 78462983, 978390652, 549050844, 914438907, 635479916, 712290713, 952385028};
tr={162, 234390, 350950482, 386282067, 205367370, 255040961, 69335800, 674099389, 175409900, 230058619, 339713735, 331852207, 320637159, 52920411, 597074996, 134213796, 72615600, 419434807, 336803919, 650878305, 392233640, 920770685, 606525473, 447023422, 359314458, 126883463};
}
if (n==24)
{
s={156466941, 524320662, 769372773, 117593719, 282693706, 143985827, 818631144, 722733213, 737023677, 259251738, 689256170, 439546578, 921007193, 628122217, 875319918, 713341950, 811710201, 844092012, 157869361, 2765662, 840574783, 888370419, 296170379, 914640256, 352837984, 489664456, 326809890, 603627451, 526080150, 547483896, 608926092, 102210282, 20136971, 959569629, 289422838, 797673615, 869541960, 16364031};
tr={486, 3300852, 486390401, 157705668, 255040961, 270067615, 890091610, 989425911, 102959090, 332786435, 7344551, 407542708, 740090735, 792716305, 972768743, 929945472, 552042418, 528849708, 241351746, 145812033, 362307018, 770413105, 132137727, 965675567, 437111021, 393854140, 154806537, 520666325, 758511492, 63190804, 997761380, 68775801, 983862923, 348139782, 601697518, 694773102, 262099573, 323944493};
}
if (n==28)
{
s={706416600, 266714259, 615548700, 810012128, 48636537, 71227083, 605828231, 373771051, 456894641, 323536863, 675248704, 108116366, 246995527, 656183777, 470402643, 44457150, 535499418, 683311574, 560356517, 186413622, 979858442, 856659946, 157821916, 641250191, 587372159, 490515907, 524793349, 864892865, 503267300, 899143630, 990349024, 519923797, 178752312, 816655560, 620680223, 206919116, 463396639, 952587026};
tr={1458, 46485102, 156888273, 324635103, 69335800, 890091610, 524120255, 410842735, 604774367, 333642960, 253967953, 735298387, 959647355, 71320846, 584013059, 398542755, 106060719, 648301890, 386812262, 868018307, 424953977, 711033721, 34094521, 364601234, 821612342, 175909022, 439617221, 930911053, 147554697, 253448742, 518078171, 957480805, 805410011, 68489461, 686764013, 589615784, 798447325, 322145279};
}
cout<<linearRec(tr,s,m/4-1)<<en;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
4 4
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 8
output:
0
result:
ok "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
12 3456
output:
491051233
result:
ok "491051233"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 1
output:
0
result:
ok "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
20 999999999999999983
output:
0
result:
ok "0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
24 999999999999999994
output:
0
result:
ok "0"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
24 999999999999999955
output:
0
result:
ok "0"
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3856kb
input:
28 999999999999999928
output:
419910054
result:
wrong answer 1st words differ - expected: '846645622', found: '419910054'