QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296142 | #7775. 【模板】矩阵快速幂 | zhouhuanyi | 0 | 0ms | 3788kb | C++14 | 1.3kb | 2024-01-02 11:08:02 | 2024-01-02 11:08:03 |
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=1;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)
ans[j]=min(ans[j],(sk-(i<<1)+j)*minn[i]+(s[i]<<1)-s[j]);
for (int i=1;i<=n;++i) printf("%d ",ans[i]%mod);
puts("");
}
else
{
for (int i=1;i<=n;++i) res=(__int128)(tk-(n<<1)+i)*minn[i]+(s[n]<<1)-s[i],printf("%d ",MD2(res%mod));
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: 0ms
memory: 3788kb
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:
0 0 0 0 856550090 856550090 856550090 856550090 856550090 714855827 714855827 714855827 573161564 573161564 431467301 431467301 431467301 431467301 289773038 148078775 148078775 148078775 148078775 148078775 6384512 6384512 6384512 6384512 6384512 6384512 6384512 6384512 6384512 862934602 862934602 ...
result:
wrong answer 1st numbers differ - expected: '395495792', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 3748kb
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:
961817438 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 477438628 ...
result:
wrong answer 1st numbers differ - expected: '-1', found: '961817438'
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%