QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296143 | #7775. 【模板】矩阵快速幂 | zhouhuanyi | 0 | 1ms | 3620kb | C++14 | 1.4kb | 2024-01-02 11:11:33 | 2024-01-02 11:11:33 |
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&&!((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[i]+(s[n]<<1)-s[i],printf("%d ",MD2(res%mod));
else printf("-1 ");
}
puts("");
}
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3612kb
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: 1ms
memory: 3620kb
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 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -1 191926586 -...
result:
wrong answer 2nd numbers differ - expected: '313446627', found: '191926586'
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%