QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734390#9569. SubwayBreakPlusCompile Error//C++142.2kb2024-11-11 09:40:562024-11-11 09:40:56

Judging History

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

  • [2024-11-11 09:40:56]
  • 评测
  • [2024-11-11 09:40:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
void init(){ }
const int B = 550;
int n,k,a[200005],b[200005],id[400005],bel[400005],nxt[400005],w[400005];
struct cmp{
	bool operator()(const int &x, const int &y){
		return a[bel[x]]!=a[bel[y]]?a[bel[x]]<a[bel[y]]:x<y;
	}
};
vector<int>t[200005];
set<int,cmp>v[200005];
bool vis[400005];
ll dis[400005], ans[200005];
priority_queue<pair<int,ll>, vector<pair<int,ll>>, greater<pair<int,ll>>>q;

void procedure(){
	n=read(), k=read();
	for(int i=1;i<=k;i++) a[i]=read();
	for(int i=1;i<=k;i++) b[i]=read();

	for(int i=1;i<=k;i++){
		int q=read();
		for(int j=1;j<=q;j++){
			id[++cnt]=read(); bel[cnt]=i; v[id[cnt]].insert(cnt);
			if(j<q) nxt[cnt]=cnt+1, w[cnt]=read();
		} 
	}

	memset(dis, 0x3f, sizeof(dis));
	memset(ans, 0x3f, sizeof(ans));
	for(auto x: v[1]){
		dis[x] = 0; q.push(mkp(0, x));
	}
	v[1].clear();
	while(!q.empty()){
		int x=q.top().se; q.pop();
		if(vis[x]) continue; vis[x]=1;

		if(nxt[x] && dis[nxt[x]] > dis[x] + w[x]){
			dis[nxt[x]] = dis[x] + w[x];
			q.push(mkp(dis[nxt[x]], nxt[x]));
		}

		if(id[x]==1) continue;
		v[id[x]].erase(x);
		t[id[x]].pb(x);
		if(!v[id[x]].size()) continue;

		int y = *v[id[x]].begin();
		for(auto i: t[id[x]]){
			dis[y] = min(dis[y], dis[i] + 1ll * b[bel[i]] * a[bel[y]]);
		}
		q.push(mkp(dis[y], y));
	}
	for(int i=1;i<=cnt;i++) ans[id[i]] = min(ans[id[i]], dis[i]);
	for(int i=2;i<=n;i++) printf("%lld ", ans[i]);
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T=1;
	init();
	while(T--) procedure();
	return 0;
}

詳細信息

answer.code: In function ‘void procedure()’:
answer.code:50:30: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   50 |                         id[++cnt]=read(); bel[cnt]=i; v[id[cnt]].insert(cnt);
      |                              ^~~
      |                              int
answer.code:81:24: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   81 |         for(int i=1;i<=cnt;i++) ans[id[i]] = min(ans[id[i]], dis[i]);
      |                        ^~~
      |                        int