求助,厌 long long 代码

P2886 [USACO07NOV] Cow Relays G

@[lisida0820](/user/629192) scanf???
by JackMerryYoung @ 2022-08-28 20:27:41


@[JackMerryYoung](/user/224558) 我用的是快读快写,并且运行后直接结束了,连读入都没有
by lisida0820 @ 2022-08-28 20:28:47


@[lisida0820](/user/629192) 你的 `N` 是多少?
by AZN_0975 @ 2022-08-28 20:30:12


@[AZN_0975](/user/476985) 510
by lisida0820 @ 2022-08-28 20:31:23


```cpp #include <bits/stdc++.h> namespace IO{ #define LL long long inline LL read(){ LL x=0,f=1;char c=getchar(); for (;!isdigit(c);c=getchar())if (c=='-')f=-1; for (;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48); return x*f; } inline void write(LL x,char c='\n'){ if (x){ if (x<0)x=-x,putchar('-'); char a[30];short l; for (l=0;x;x/=10)a[l++]=x%10^48; for (l--;l>=0;l--)putchar(a[l]); }else putchar('0');putchar(c); } }using namespace IO; using namespace std; const int N = 5e2+10; const int M = 1e6+10; struct Matrix{ int a[N][N]; Matrix(){memset(a,0x3f3f3f3f,sizeof(a));} }A,ans;int n,s,t,e,tot,dfn[M]; Matrix operator * (const Matrix &x,const Matrix &y){ Matrix res; for (int k=1;k<=tot;k++) for (int i=1;i<=tot;i++) for (int j=1;j<=tot;j++) res.a[i][j]=min(res.a[i][j],x.a[i][k]+y.a[k][j]); return res; } int main(){ n=read(),t=read(),s=read(),e=read(); for (int i=1;i<=t;i++){ int z=read(),x=read(),y=read(); if (!dfn[x])dfn[x]=++tot; if (!dfn[y])dfn[y]=++tot; A.a[dfn[x]][dfn[y]]=A.a[dfn[y]][dfn[x]]=z; } ans=A;int b=n-1; for (;b;b>>=1,A=A*A)if (b&1)ans=ans*A; write(ans.a[dfn[s]][dfn[e]]); return 0; }
by lisida0820 @ 2022-08-28 20:33:38


@[lisida0820](/user/629192) 没问题啊,编译器出锅了吧
by simonG @ 2022-08-28 20:34:40


@[lisida0820](/user/629192) 在洛谷ide上测样例输出了正确答案,应该是您编译器的问题?
by sunrise1024 @ 2022-08-28 20:34:49


@[gaosichensb](/user/253936) @[sunrise1024](/user/368884) 好吧,谢谢大佬
by lisida0820 @ 2022-08-28 20:36:36


是的 并且建议用memset(a,0x3f3f,sizeof(a));
by 康立扬 @ 2022-08-28 20:37:26


@[康立扬](/user/251811) 您这个真的不会寄吗?memsset按字节赋值的,您这个数有俩字节
by sunrise1024 @ 2022-08-28 20:39:04


| 下一页