QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296144 | #7775. 【模板】矩阵快速幂 | zhouhuanyi | 0 | 1ms | 3632kb | C++14 | 1.4kb | 2024-01-02 11:15:08 | 2024-01-02 11:15:08 |
answer
#include<iostream>
#include<cstdio>
#define N 300
#define mod 998244353
using namespace std;
const __int128 inf=(__int128)(1e19);
const __int128 INF=(__int128)(1e37);
long long read()
{
char c=0;
long long sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int MD2(int x)
{
return x<0?x+mod:x;
}
int S,T,n,m,tk;
long long delta[N+1],minn[N+1];
__int128 sk,ans[N+1],s[N+1],sminn;
string k;
int main()
{
int x,y;
long long z;
__int128 res;
S=read(),T=read();
while (T--)
{
n=read(),m=read(),sk=tk=0,cin>>k;
for (int i=0;i<k.length();++i) sk=min(sk*10+k[i]-'0',inf),tk=(tk*10ll+k[i]-'0')%mod;
for (int i=1;i<=m;++i) x=read(),y=read(),z=read(),delta[max(x,y)]=z;
for (int i=2;i<=n;++i) s[i]=s[i-1]+delta[i];
for (int i=2;i<=n;++i) minn[i]=i==2?delta[i]:min(minn[i-1],delta[i]);
if (sk!=inf)
{
for (int i=1;i<=n;++i) ans[i]=INF;
for (int i=2;i<=n;++i)
for (int j=1;j<=i;++j)
if (sk>=(i<<1)+j&&!((sk-(i<<1)+j+1)&1))
ans[j]=min(ans[j],(sk-(i<<1)+j+1)*minn[i]+(s[i]<<1)-s[j]);
for (int i=1;i<=n;++i) printf("%d ",ans[i]==INF?-1:ans[i]%mod);
puts("");
}
else
{
for (int i=1;i<=n;++i)
{
if (((i-1)&1)==(k[(int)(k.length())-1]&1)) res=(__int128)(tk-(n<<1)+i+1)*minn[n]+(s[n]<<1)-s[i],printf("%d ",MD2(res%mod));
else printf("-1 ");
}
puts("");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3632kb
input:
1 1 100 101 899539897889989959 74 35 910832669819965536 35 85 910832669819965536 85 88 910832669819965536 88 30 910832669819965536 30 58 910832669819965536 58 60 910832669819965536 60 34 910832669819965536 34 8 910832669819965536 8 67 910832669819965536 67 89 910832669819965536 89 32 910832669819965...
output:
-1 0 -1 0 -1 856550090 -1 856550090 -1 714855827 -1 714855827 -1 573161564 -1 431467301 -1 431467301 -1 148078775 -1 148078775 -1 148078775 -1 6384512 -1 6384512 -1 6384512 -1 6384512 -1 862934602 -1 721240339 -1 437851813 -1 437851813 -1 437851813 -1 154463287 -1 869319114 -1 585930588 -1 302542062...
result:
wrong answer 1st numbers differ - expected: '395495792', found: '-1'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 3628kb
input:
2 1 300 598 8179377797889487867988994778539839593376697796496698959964978969 1 2 977880533270721156 2 1 977880533270721156 2 3 977880533270721156 3 2 977880533270721156 3 4 977880533270721156 4 3 977880533270721156 4 5 977880533270721156 5 4 977880533270721156 5 6 977880533270721156 6 5 977880533270...
output:
-1 313680353 -1 313670191 -1 313660029 -1 313649867 -1 313639705 -1 313629543 -1 313619381 -1 313609219 -1 313599057 -1 313588895 -1 313578733 -1 313568571 -1 313558409 -1 313548247 -1 313538085 -1 313527923 -1 313517761 -1 313507599 -1 313497437 -1 313487275 -1 313477113 -1 313466951 -1 313456789 -...
result:
wrong answer 2nd numbers differ - expected: '313446627', found: '313680353'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #3:
0%