QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727359#9569. Subwayucup-team3555#Compile Error//C++202.4kb2024-11-09 12:56:542024-11-09 12:56:55

Judging History

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

  • [2024-11-09 12:56:55]
  • 评测
  • [2024-11-09 12:56:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef array<ll,2> Nod;
const ll N=4e5+3,V=1e6,INF=1e18;
ll n,m,rt[N],a[N],b[N],len[N],ans[N];
vector<ll>ve[N],W[N];
map<ll,ll>mp[N],F[N];
struct Cmp{bool operator()(int X,int Y){return b[X]!=b[Y]?b[X]<b[Y]:X<Y;}};
set<ll,Cmp>S[N];
set<Nod>Q,q[N];
ll Ans(ll x,ll id,ll z){return F[x].count(id)?F[x][id]+a[x]*z:INF;}
struct LCT
{
	ll tot,tr[N],lc[N],rc[N];
	#define ls lc[p]
	#define rs rc[p]
	#define mi ((l+r)>>1)
	void Upd(ll u,ll id,ll &p,ll l=0,ll r=V)
	{
		if(!p)p=++tot;
		ll &v=tr[p];
		if(!v){v=u;return;}
		if(Ans(u,id,mi)<Ans(v,id,mi))swap(u,v);
		if(Ans(u,id,l)<Ans(v,id,l))Upd(u,id,ls,l,mi);
		if(Ans(u,id,r)<Ans(v,id,r))Upd(u,id,rs,mi+1,r);
	}
	ll Ask(ll d,ll id,ll p,ll l=0,ll r=V)
	{
		if(!p)return INF;
		ll s=Ans(tr[p],id,d);
		return min(s,d<=mi?Ask(id,d,ls,l,mi):Ask(id,d,rs,mi+1,r));
	}
}T;
void Make(int x,int y,ll z)
{
	if(!F[x].count(y))F[x][y]=z;
	else F[x][y]=min(F[x][y],z);
}
void Era(int x,int id)
{
	Q.erase({(*q[id].begin())[0],id});
	q[id].erase({F[x][id],x});S[id].erase(x); 
	int y=!S[id].size()?0:*S[id].begin();
	if(y)
	{
		q[id].erase({F[y][id],y}); 
		Make(y,id,T.Ask(b[y],rt[id],rt[id]));
		q[id].insert({F[y][id],y});
	}
	Q.insert({(*q[id].begin())[0],id});
}
void Upd(int x,int id)
{
	int now=mp[x][id];
	T.Upd(x,id,rt[id]);Era(x,id);
	if(now==len[x]-1)return;
	int to=ve[x][now+1];
	Q.erase({(*q[to].begin())[0],to});
	q[to].erase({F[x][to],x}); 
	Make(x,to,F[x][id]+W[x][now]);
	q[to].insert({F[x][to],x});
	Q.insert({(*q[to].begin())[0],to});
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>b[i];
	for(int i=1;i<=m;i++)cin>>a[i];
	for(int i=1;i<=n;i++)ans[i]=INF,q[i].insert({INF,0});
	for(int i=1;i<=m;i++)
	{
		cin>>len[i];ve[i].resize(len[i]);W[i].resize(len[i]);
		for(int j=0;j<len[i];j++)
		{
			int x=0,y=0;cin>>x;ve[i][j]=x;
			if(x==1)F[i][x]=0;
			else F[i][x]=INF;
			if(j<len[i]-1)cin>>y;
			mp[i][x]=j,W[i][j]=y;
			S[x].insert(i);
			q[x].insert({F[i][x],i});
		}
	}
	for(int i=1;i<=n;i++)Q.insert({(*q[i].begin())[0],i});
	while(Q.size())
	{
		Nod t=*Q.begin();
		if(t[0]>=INF)break;
		int id=t[1],x=(*q[id].begin())[1];Upd(x,id);
	}
	for(int i=1;i<=m;i++)for(auto t:F[i])ans[t.first]=min(ans[t.first],t.second);
	for(int i=2;i<=n;i++)cout<<ans[i]<<" ";
}

詳細信息

In file included from /usr/include/c++/13/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = Cmp; _Alloc = std::allocator<long long int>; _Const_Link_type = const std::_Rb_tree_node<long long int>*]’:
/usr/include/c++/13/bits/stl_tree.h:2020:37:   required from ‘std::pair<std::_Rb_tree_iterator<_Val>, std::_Rb_tree_iterator<_Val> > std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::equal_range(const _Key&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = Cmp; _Alloc = std::allocator<long long int>]’
/usr/include/c++/13/bits/stl_tree.h:2519:49:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::erase(const _Key&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = Cmp; _Alloc = std::allocator<long long int>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_set.h:687:26:   required from ‘std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = long long int; _Compare = Cmp; _Alloc = std::allocator<long long int>; size_type = long unsigned int; key_type = long long int]’
answer.code:44:39:   required from here
/usr/include/c++/13/bits/stl_tree.h:772:15: error: static assertion failed: comparison object must be invocable as const
  772 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_tree.h:772:15: note: ‘std::is_invocable_v<const Cmp&, const long long int&, const long long int&>’ evaluates to false