Language: C++

#include<cstdio>#include<cstring>#include<cmath>#include<string>#include<iostream>#include<algorithm>#include<map>#include<queue>#include<set>#include<vector>using namespace std;typedef long long ll;const int N=2005;const ll INF=1e11+7;#define de(x) cout<<#x<<" = "<<x<<endl;#define pb push_back#define fi first#define se second#define mp make_pair#define pii pair<int,int>//--------------------------------------//int cnt,last[N];void init() {    cnt=0;    memset(last,-1,sizeof last);}struct edge {      int to,pre,cost;}es[2*N];void addEdge(int u,int v,int w) {    edge e={v,last[u],w};    es[++cnt]=e;    last[u]=cnt;}bool vis[N];ll dis[N];int cntt[N];bool SPFA(int s,int n) {    memset(cntt,0,sizeof cnt);    memset(vis,false,sizeof vis);    for(int i=1;i<=n;++i) dis[i]=-INF;    vis[s]=true;    dis[s]=0;    queue<int> que;    que.push(s);    while(!que.empty()) {        int u=que.front(); que.pop();        vis[u]=false;        for(int i=last[u];i!=-1;i=es[i].pre) {            int v=es[i].to;            if(dis[u]+es[i].cost>dis[v]) {                dis[v]=dis[u]+es[i].cost;                if(!vis[v]) {                    vis[v]=true;                    que.push(v);                    if(++cntt[v]>n) return false;//存在环                }            }        }    }    return true;}int main() {    int n,m,a,b,c;    while(~scanf("%d%d",&n,&m)) {        init();        for(int i=1;i<=m;++i) {            scanf("%d%d%d",&a,&b,&c);            addEdge(a,b,c);        }        if(SPFA(1,n)) {            printf("%I64d\n",dis[n]);        } else puts("inf");    }    return 0;}

Compiler output:
a.cc:1:17: warning: extra tokens at end of #include directive
    1 | #include<cstdio>#include<cstring>#include<cmath>#include<string>#include<iostream>#include<algorithm>#include<map>#include<queue>#include<set>#include<vector>using namespace std;typedef long long ll;const int N=2005;const ll INF=1e11+7;#define de(x) cout<<#x<<" = "<<x<<endl;#define pb push_back#define fi first#define se second#define mp make_pair#define pii pair<int,int>//--------------------------------------//int cnt,last[N];void init() {    cnt=0;    memset(last,-1,sizeof last);}struct edge {      int to,pre,cost;}es[2*N];void addEdge(int u,int v,int w) {    edge e={v,last[u],w};    es[++cnt]=e;    last[u]=cnt;}bool vis[N];ll dis[N];int cntt[N];bool SPFA(int s,int n) {    memset(cntt,0,sizeof cnt);    memset(vis,false,sizeof vis);    for(int i=1;i<=n;++i) dis[i]=-INF;    vis[s]=true;    dis[s]=0;    queue<int> que;    que.push(s);    while(!que.empty()) {        int u=que.front(); que.pop();        vis[u]=false;        for(int i=last[u];i!=-1;i=es[i].pre) {            int v=es[i].to;            if(dis[u]+es[i].cost>dis[v]) {                dis[v]=dis[u]+es[i].cost;                if(!vis[v]) {                    vis[v]=true;                    que.push(v);                    if(++cntt[v]>n) return false;//存在环                }            }        }    }    return true;}int main() {    int n,m,a,b,c;    while(~scanf("%d%d",&n,&m)) {        init();        for(int i=1;i<=m;++i) {            scanf("%d%d%d",&a,&b,&c);            addEdge(a,b,c);        }        if(SPFA(1,n)) {            printf("%I64d\n",dis[n]);        } else puts("inf");    }    return 0;}
      |                 ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status