QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120855#6660. 택시 여행youngsystem#Compile Error//C++202.8kb2023-07-07 11:53:502024-07-04 00:26:42

Judging History

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

  • [2024-07-04 00:26:42]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-07 11:53:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long a[200005],b[200005];
vector<int>v[200005];
vector<long long>bq[200005];
int pos[200005],cnt;
bool bi(int x,int y)
{
	return b[x]>b[y];
}
long long dep[200005];
long long dis[200005];
void dfs(int x,int f,long long qz)
{
	dis[x]=min(dis[x],dep[x]);
	//printf("%lld %lld\n",x,dep[x]);
	for(int i=0;i<v[x].size();i++)
	{
		if(v[x][i]==f)continue;
		dep[v[x][i]]=dep[x]+qz*bq[x][i];
		dfs(v[x][i],x,qz);
	}
}
long long qzh[200005];
void insert(int& k,long long l,long long r,long long nk,long long nb)
{
	if(k==0)k=++cnt;
	if(!vis[k])
	{
		vis[k]=true;
		tk[k]=nk;
		tb[k]=nb;
		return;
	}
	long long mid=((l+r)>>1);
	long long pz=tk[k]*mid+tb[k],nz=nk*mid+nb;
	if(pz>nz)
	{
		swap(pz,nz);
		swap(tk[k],nk);
		swap(tb[k],nb);
	}
	if(l==r)return;
	if(nk>tk[k])insert(ch[k][0],l,mid,nk,nb);
	else insert(ch[k][1],mid+1,r,nk,nb);
}
long long query(int k,long long l,long long r,long long x)
{
	if(k==0||vis[k]==false)return 1000000000000000000LL;
	long long ans=tk[k]*x+tb[k];
	//printf("%lld %lld %lld %lld\n",tk[k],tb[k],x,ans);
	if(l==r)return ans;
	long long mid=((l+r)>>1);
	if(x<=mid)ans=min(ans,query(ch[k][0],l,mid,x));
	else ans=min(ans,query(ch[k][1],mid+1,r,x));
	return ans;
}
std::vector<long long> travel(std::vector<long long> A,
        std::vector<int> B, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    int n = A.size();
    for(int i=1;i<=n;i++)a[i]=A[i-1],b[i]=B[i-1];
    int sl=0;
    for(int i=1;i<=n;i++)if(b[i]!=0)sl++;
    for(int i=0;i<n-1;i++)
    {
    	U[i]++;
    	V[i]++; 
    	v[U[i]].push_back(V[i]);
    	v[V[i]].push_back(U[i]);
    	bq[U[i]].push_back(W[i]);
    	bq[V[i]].push_back(W[i]);
	}
	dis[1]=0;
	for(int i=2;i<=n;i++)dis[i]=1000000000000000000LL;
    if(sl<=2000)
    {
    	for(int i=1;i<=n;i++)if(b[i]!=0)pos[++cnt]=i;
    	sort(pos+1,pos+cnt+1,bi);
    	for(int ii=1;ii<=cnt;ii++)
    	{
    		int i=pos[ii];
    		if(dis[i]==1000000000000000000LL)continue;
    		dep[i]=dis[i]+a[i];
    		dfs(i,0,b[i]);
		}
		long long minn=1000000000000000000LL;
		for(int i=1;i<=n;i++)if(b[i]==0)minn=min(minn,dis[i]+a[i]);
		for(int i=1;i<=n;i++)dis[i]=min(dis[i],minn);
		vector<long long>qans;
		for(int i=2;i<=n;i++)qans.push_back(dis[i]);
		return qans;
	}
	bool flag=true;
	for(int i=1;i<=n-1;i++)
	{
		if(U[i]!=i||V[i]!=i+1)
		{
			flag=false;
			break;
		}
	}
	if(flag==true)
	{
		qzh[1]=0;
		for(int i=2;i<=n;i++)qzh[i]=qzh[i-1]+W[i-2];
		int rt=0;
		insert(rt,1,qzh[n],b[i],a[i]);
		for(int i=2;i<=n;i++)
		{
			dis[i]=query(rt,1,qzh[n],qzh[i]);
			insert(rt,1,qzh[n],b[i],dis[i]+a[i]-b[i]*qzh[i]);
		}
		vector<long long>qans;
		for(int i=2;i<=n;i++)qans.push_back(dis[i]);
		return qans;
	}
	vector<long long>v;
	for(int i=2;i<=n;i++)v.push_back(0);
	return v;
}

詳細信息

answer.code: In function ‘void insert(int&, long long int, long long int, long long int, long long int)’:
answer.code:28:13: error: ‘vis’ was not declared in this scope; did you mean ‘dis’?
   28 |         if(!vis[k])
      |             ^~~
      |             dis
answer.code:31:17: error: ‘tk’ was not declared in this scope; did you mean ‘k’?
   31 |                 tk[k]=nk;
      |                 ^~
      |                 k
answer.code:32:17: error: ‘tb’ was not declared in this scope; did you mean ‘nb’?
   32 |                 tb[k]=nb;
      |                 ^~
      |                 nb
answer.code:36:22: error: ‘tk’ was not declared in this scope; did you mean ‘k’?
   36 |         long long pz=tk[k]*mid+tb[k],nz=nk*mid+nb;
      |                      ^~
      |                      k
answer.code:36:32: error: ‘tb’ was not declared in this scope; did you mean ‘nb’?
   36 |         long long pz=tk[k]*mid+tb[k],nz=nk*mid+nb;
      |                                ^~
      |                                nb
answer.code:37:15: error: ‘nz’ was not declared in this scope; did you mean ‘pz’?
   37 |         if(pz>nz)
      |               ^~
      |               pz
answer.code:44:28: error: ‘ch’ was not declared in this scope
   44 |         if(nk>tk[k])insert(ch[k][0],l,mid,nk,nb);
      |                            ^~
answer.code:45:21: error: ‘ch’ was not declared in this scope
   45 |         else insert(ch[k][1],mid+1,r,nk,nb);
      |                     ^~
answer.code: In function ‘long long int query(int, long long int, long long int, long long int)’:
answer.code:49:18: error: ‘vis’ was not declared in this scope; did you mean ‘dis’?
   49 |         if(k==0||vis[k]==false)return 1000000000000000000LL;
      |                  ^~~
      |                  dis
answer.code:50:23: error: ‘tk’ was not declared in this scope; did you mean ‘k’?
   50 |         long long ans=tk[k]*x+tb[k];
      |                       ^~
      |                       k
answer.code:50:31: error: ‘tb’ was not declared in this scope; did you mean ‘tm’?
   50 |         long long ans=tk[k]*x+tb[k];
      |                               ^~
      |                               tm
answer.code:54:37: error: ‘ch’ was not declared in this scope
   54 |         if(x<=mid)ans=min(ans,query(ch[k][0],l,mid,x));
      |                                     ^~
answer.code:55:32: error: ‘ch’ was not declared in this scope
   55 |         else ans=min(ans,query(ch[k][1],mid+1,r,x));
      |                                ^~
answer.code: In function ‘std::vector<long long int> travel(std::vector<long long int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)’:
answer.code:108:38: error: ‘i’ was not declared in this scope
  108 |                 insert(rt,1,qzh[n],b[i],a[i]);
      |                                      ^