Submission #939448

# Submission time Handle Problem Language Result Execution time Memory
939448 2024-03-06T11:24:18 Z koukirocks Robot (JOI21_ho_t4) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=1e5+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;

ll n,m;

struct edge{
	ll des,clr,cst;
	edge(ll _des,ll _clr,ll _cst):des(_des),clr(_clr),cst(_cst){}
};

vector<edge> G[MAX];
vector<pll> G2[MAX*3];

int main() {
	speed;
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		ll a,b,c,p;
		cin>>a>>b>>c>>p;
		G[a].emplace_back(b,c,p);
		G[b].emplace_back(a,c,p);
		G2[a].emplace_back(b,p);
		G2[b].emplace_back(a,p);
	}
	ll now=n+1;
	for (int i=1;i<=n;i++) {
		map<int,vector<pll> > ttl;
		for (auto eg:G[i]) ttl[eg.clr].emplace_back(eg.des,eg.cst);
		for (auto [clr,egs]:ttl) {
			ll ttlw=0;
			for (auto eg:egs) ttlw+=eg.second;
			G2[i].push_back({now,0});
			for (auto eg:egs) {
				G2[now].emplace_back(eg.first,ttlw-eg.second);
				G2[eg.first].emplace_back(now,0);
			}
//			cout<<i<<" "<<clr<<" "<<now<<"\n";
			now++;
		}
	}
//	for (int i=1;i<now;i++) {
//		cout<<i<<".\n";
//		for (auto j:G2[i]) {
//			cout<<j.first<<" "<<j.second<<"\n";
//		}
//		cout<<"----\n";
//	}
	priority_queue<pll> D;
	vector<bool> vis(now+1,0);
	vector<ll> dis(now+1,oo);
	dis[1]=0;
	D.emplace(0,1);
	while (!D.empty()) {
		while (!D.empty() and vis[D.top().second]) D.pop();
		if (D.empty()) break;
		int v=D.top().second;
		D.pop();
		vis[v]=true;
		for (auto [u,w]:G2[v]) {
			if (!vis[u] and dis[v]+w<dis[u]) {
				dis[u]=dis[v]+w;
				D.emplace(-dis[u],u);
			}
		}
	}
	cout<<(dis[n]==oo?"-1":dis[n])<<"\n";
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:77:19: error: operands to '?:' have different types 'const char*' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   77 |  cout<<(dis[n]==oo?"-1":dis[n])<<"\n";