제출 #1157711

#제출 시각아이디문제언어결과실행 시간메모리
1157711yf_yusufEscape Route (JOI21_escape_route)C++20
컴파일 에러
0 ms0 KiB
//```//    YF YUSUF
#define Free_open(File) freopen((File".in"),"r",stdin);freopen((File".out"),"w",stdout);
#define YF ios_base::sync_with_stdio(0);cout.setf(ios::fixed);
#define YUSUF cout.precision(0);cout.tie(0);cin.tie(0);
#include <bits/stdc++.h>
using namespace std;
#ifdef YF_CHECK
	bool Output=1;
	#include "g/debug.h"
	//#include "g/bigint.h"
	//#include "g/text.h"
#else
	bool Output=0;
	#define deb(x...) 42 
#endif
using ll  =  long long;
//using ld  =  long double;
using vll =  vector <ll>;
using mll =  map <ll,ll>;
using pll =  pair <ll,ll>;
using vpll=  vector <pll>;
template<class T>T MIN(T&a,T b){a=min(a,b);return a;}
template<class T>T MAX(T&a,T b){a=max(a,b);return a;}
#define revers(a) reverse(all(a))
#define all(a) a.begin(),a.end()
#define sortt(a) sort(all(a))
#define sgr v+v+1,tm+1,tr
#define sgl v+v,tl,tm
#define pb push_back
#define ins insert
#define S second
#define F first
#define int ll
ll BP(ll a,ll b,ll mod=1e9+7){
	if(b==0)return 1;
	ll q=BP(a,b/2,mod);
	return ((q*q)%mod*(b%2?a:1ll))%mod;
}
ll dup(ll a,ll b){return (a+b-1)/b;}
ll f(ll x){return x*(x+1)/2;}
const int mod=998244353;
const int INF=1e18+7;
const int inf=1e9+7;
const int N  =1e6+7;
struct edge{
	ll to,t,b;
};
struct cmp {
  bool operator()(const edge &a, const edge &b) const {
    return a.t<b.t;
  }
};
vector<edge>g[N];
ll n,S;
ll bfs(ll s,ll f,ll t){
	set<edge,cmp>q;
	q.ins({s,0,t});
	vll d(n+1,INF);
	d[s]=0;
	while(q.size()){
		auto [v,D,nowd]=*q.begin();
		q.erase({v,D,nowd});
		MIN(d[v],D);
		for(auto [to,t,b] : g[v]){
			if(d[to]>D+t){
//					deb(v,to,D, t,S ,nowd   );
				if(b>=nowd+t){
//					deb(to, D+t,   nowd+t);
					q.ins({to,D+t,nowd+t});
					MIN(d[to],D+t);
				}
				if(b>=t){
//					deb(to,D+t+S-nowd,t);
					q.ins({to,D+t+(S-nowd),t});
					MIN(d[to],D+t+S-nowd);
				}
			}
		}
	}
	return d[f];
}
void YF_MAIN(ll TEST){
	ll m,q;
	cin>>n>>m>>S>>q;
	for(int i=1;i<=m;i++){
		ll x,y,t,b;
		cin>>x>>y>>t>>b;
		g[x].pb({y,t,b});
		g[y].pb({x,t,b});
	}
	while(q--){
		ll s,f,t;
		cin>>s>>f>>t;
		cout<<bfs(s,f,t)<<"\n";
	}
}
bool TECT=0;
bool CASE=0;
bool OUTP=1;
//ll FACT[N],inv[N],FMOD=1e9+7;
//ll PER(ll n,ll k){return FACT[n] *inv[n-k]%FMOD;}
//ll CNK(ll n,ll k){return PER(n,k)*inv[k  ]%FMOD;}
//ll lg[N];
void BEFORE(){
	return;
//	for(int i=2;i<=200000;i++){
//		lg[i]=lg[i/2]+1;
//	}
//	FACT[0]=inv[0]=1;
//	for(int i=1;i<=1e6;i++){
//		FACT[i]=FACT[i-1]*i%FMOD;
//		inv[i]=BP(FACT[i],FMOD-2,FMOD);
//	}
}
signed main(){
	if(OUTP){YF YUSUF}
//	Free_open("TEST");
	cout<<(Output ? "\nYF_OUTPUT:\n\n" : "");
	int TEST=1;
	if(TECT)
		cin>>TEST;
	BEFORE();
	for(int T=1;T<=TEST;T++){
		if(CASE)
			cout<<"Case "<<T<<": ";
		YF_MAIN(T);
		cout<<(T==TEST ? "" : "\n");
	}
	return 0;
} 
//```

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccX1oVZ4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccvtC9ZJ.o:escape_route.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccX1oVZ4.o: in function `main':
grader.cpp:(.text.startup+0x6e0): undefined reference to `calculate_necessary_time(int, int, long long, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<long long, std::allocator<long long> >, std::vector<long long, std::allocator<long long> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<long long, std::allocator<long long> >)'
collect2: error: ld returned 1 exit status