QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#429816#8136. Rebellious EdgelmeowdnCompile Error//C++141.9kb2024-06-02 21:40:212024-06-02 21:40:22

Judging History

你现在查看的是最新测评结果

  • [2024-06-02 21:40:22]
  • 评测
  • [2024-06-02 21:40:21]
  • 提交

answer

//Shirasu Azusa 2024.6
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;  
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=5e5+5,inf=0x3f3f3f3f3f3f3f3f;
int n,m,g[N],ans,sp,vst[N],id[N],f[N];
struct ed {int u,v,w;} e[N];
vi p[N];

void work() {
  n=read(), m=read();
  rep(i,1,n) p[i].clear(), f[i]=0;
  rep(i,1,m) {
    e[i].u=read(), e[i].v=read(), e[i].w=read();
    if(e[i].u>e[i].v) sp=i; p[e[i].u].eb(i);
  }
  ans=0;
  rep(i,1,n) g[i]=0; e[0].w=inf;
  rep(i,1,m) {
    if(e[g[e[i].v]].w>e[i].w) {
      g[e[i].v]=i;
    }
  }
  bool flag=0;
  rep(i,1,n) if(g[i]) ans+=e[g[i]].w;
  rep(i,1,n) flag|=(g[i]==sp);
  if(flag) {
    rep(i,2,n) f[i]=inf;
    rep(i,1,n) {
      for(int j:p[i]) chmin(f[e[j].v],f[i]+e[j].w-e[g[e[j].v]].w);
    }
  }z
  printf("%lld\n",ans+f[e[sp].u]);
}

signed main() {
  int T=read(); while(T--) work();
  return 0;
}

Details

answer.code: In function ‘void work()’:
answer.code:64:4: error: ‘z’ was not declared in this scope
   64 |   }z
      |    ^