QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#443247 | #8743. 转化 | Jowaire | WA | 146ms | 5220kb | C++14 | 1.0kb | 2024-06-15 14:54:18 | 2024-06-15 14:54:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
const int N=103,M=1003;
ll n,m,sum,a[N],f[N],g[N],c[M],len[M],b[M][N];
void write(ll X)
{
if(X<0){putchar('-');X=~(X-1);}
int s[50],o=0;
while(X){s[++o]=X%10;X/=10;}
if(!o)s[++o]=0;while(o)putchar(s[o--]+'0');
putchar('\n');
}
int main()
{
int _n,_m;cin>>_n>>_m;n=_n;m=_m;
for(int i=1,x;i<=n;i++)cin>>x,a[i]=x,sum+=n*a[i];
for(int i=1;i<=m;i++)
{
int _c,_len;cin>>_c>>_len;c[i]=_c;len[i]=_len;
for(int j=1,x;j<=len[i];j++)cin>>x,b[i][j]=x;
}
for(int t=1;t<=n;t++)
{
ll fl=0,lim=n*n*n;
for(int i=1;i<=n;i++)f[i]=i==t;
for(int tim=1;tim<=lim;tim++)
{
for(int i=1;i<=n;i++)g[i]=f[i];
for(int i=1;i<=m;i++)
{
ll x=0;
for(int j=1;j<=len[i];j++)x+=g[b[i][j]];
f[c[i]]=max(f[c[i]],x);
}
ll cnt=0;
for(int i=1;i<=n;i++)cnt+=f[i]==g[i];
if(cnt==n)break;
fl|=tim==lim;//assert(0);
}
ll s=0;
for(int i=1;i<=n;i++)s+=f[i]*a[i];
if(s>(ll)1e25)cout<<"infinity"<<endl;
else write(s);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 146ms
memory: 5220kb
input:
100 1000 327 833 558 253 722 710 811 779 789 919 750 288 611 674 670 264 815 701 304 615 9 943 713 633 392 706 687 847 78 999 368 55 913 61 686 512 696 0 695 285 485 877 533 54 621 925 339 319 597 536 285 701 186 933 234 360 284 546 545 185 112 735 147 851 824 512 695 734 237 381 777 449 880 675 614...
output:
2155053232761438 infinity 965 infinity infinity 18077896788769822849609 282467137324528482092 144623174310158582796217 2007265 67345413524067 256902392 8220875576 564934274649056963984 34480851724185745 infinity 128450953 16836353381018 526136043133 infinity 137923406896742471 9038948394384911424454...
result:
wrong answer 2nd lines differ - expected: '74047065246801194391656046', found: 'infinity'