Submission #72536774


Source Code Expand

#include<bits/stdc++.h>
#include<limits.h>
#include<unordered_map>
//#include<chrono>
using namespace std;
//#define randint uniform_int_distribution<int>
#define ll long long
#define ld long double
#define Int __int128
#define ull unsigned long long
#define uint unsigned
#define pii pair<int,int>
#define pll pair<long long,long long>
#define fi first
#define se second

template<typename T>T Max(T a,T b){return a>b?a:b;}template<typename T,typename...Args>T Max(T a,Args...args){return a>Max(args...)?a:Max(args...);}
template<typename T>T Min(T a,T b){return a<b?a:b;}template<typename T,typename...Args>T Min(T a,Args...args){return a<Min(args...)?a:Min(args...);}

namespace io{const int __SIZE=(1<<21)+1;char ibuf[__SIZE],*iS,*iT,obuf[__SIZE],*oS=obuf,*oT=oS+__SIZE-1,__c,qu[55];int __f,qr,_eof;
#define Gc()(iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,__SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush(){fwrite(obuf,1,oS-obuf,stdout),oS=obuf;}inline void gc(char&x){x=Gc();}inline void pc(char x){*oS++=x;if(oS==oT)flush();}inline void pstr(const char*s){int __len=strlen(s);for(__f=0;__f<__len;++__f)pc(s[__f]);}inline void gstr(char*s){for(__c=Gc();__c<32||__c>126||__c==' ';)__c=Gc();for(;__c>31&&__c<127&&__c!=' '&&__c!='\n'&&__c!='\r';++s,__c=Gc())*s=__c;*s=0;}template<class I>inline bool gi(I&x){_eof=0;for(__f=1,__c=Gc();(__c<'0'||__c>'9')&&!_eof;__c=Gc()){if(__c=='-')__f=-1;_eof|=__c==EOF;}for(x=0;__c<='9'&&__c>='0'&&!_eof;__c=Gc())x=x*10+(__c&15),_eof|=__c==EOF;x*=__f;return!_eof;}template<class I>inline void print(I x){if(!x)pc('0');if(x<0)pc('-'),x=-x;while(x)qu[++qr]=x%10+'0',x/=10;while(qr)pc(qu[qr--]);}struct Flusher_{~Flusher_(){flush();}}io_flusher_;}using io::pc;using io::gc;using io::pstr;using io::gstr;using io::gi;using io::print;

template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{ ";string sep;for(const auto&x:v)os<<sep<<x,sep=", ";return os<<" }";}
template<typename T,size_t size>ostream&operator<<(ostream&os,const array<T,size>&arr){os<<"{ ";string sep;for(const auto&x:arr)os<<sep<<x,sep=", ";return os<<" }";}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B>&p){return os<<'('<<p.first<<","<<p.second<<')';}
template<typename K,typename V>ostream&operator<<(ostream&os,const map<K,V>&m){os<<"{ ";string sep;for(const auto&p:m)os<<sep<<p.first<<":"<<p.second,sep=", ";return os<<" }";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&s){os<<"{ ";string sep;for(const auto&x:s)os<<sep<<x,sep=", ";return os<<" }";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&s){os<<"{ ";string sep;for(const auto&x:s)os<<sep<<x,sep=", ";return os<<" }";}

namespace detail{template<typename T>constexpr bool is_string_type_v=std::is_same_v<std::decay_t<T>,std::string>||std::is_same_v<std::decay_t<T>,const char*>||std::is_same_v<std::decay_t<T>,char*>;template<typename T>void print_val(const T&val){if constexpr(is_string_type_v<T>){std::cerr<<'"'<<val<<'"';}else{std::cerr<<val;}}inline std::string_view trim(std::string_view sv){sv.remove_prefix(std::min(sv.find_first_not_of(" \t"),sv.size()));size_t end=sv.find_last_not_of(" \t");if(end!=std::string_view::npos){sv.remove_suffix(sv.size()-end-1);}return sv;}template<typename...Args>void dbgg_impl(int line,const char*msg,const char*raw_names,Args&&...args){std::cerr<<"Line "<<line<<": "<<msg;if constexpr(sizeof...(Args)>0){if(strlen(msg)>0)std::cerr<<" | ";std::string_view names(raw_names);size_t arg_idx=0;([&]{if(arg_idx>0)std::cerr<<", ";size_t comma_pos=names.find(',');std::string_view current_name=(comma_pos==std::string_view::npos)?names:names.substr(0,comma_pos);std::cerr<<trim(current_name)<<"=";print_val(args);if(comma_pos!=std::string_view::npos){names.remove_prefix(comma_pos+1);}arg_idx++;}(),...);}std::cerr<<std::endl;}}
#ifdef LOCAL_ZCZ
#define dbg(Msg,...)detail::dbgg_impl(__LINE__,Msg,#__VA_ARGS__,##__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
mt19937 rnd(time(0));

namespace Zhchz{
	constexpr int N=300010,inf=0x3f3f3f3f,base=389,mod=998244353;
	constexpr ll INF=0x3f3f3f3f3f3f3f3f,INFF=0x7f7f7f7f7f7f7f7f;
	int n,m,L,S,T,x,y,z;
	vector<pii> edge[N];
	int ans[N];
	
	void dfs(int x,int l,int sum){
		dbg("",x,l,sum);
		if(l==L){
			if(S<=sum && sum<=T){
				ans[x]=1;
			}
			return;
		}
		for(auto[y,w]:edge[x]){
			dfs(y,l+1,sum+w);
		}
	}
	
	signed main(){
#ifndef LOCAL_ZCZ
		ios::sync_with_stdio(0);
		cin.tie(0);
#endif
		cin>>n>>m>>L>>S>>T;
		for(int i=1;i<=m;i++){
			cin>>x>>y>>z;
			edge[x].push_back({y,z});
		}
		dfs(1,0,0);
		for(int i=1;i<=n;i++){
			if(ans[i]) cout<<i<<" ";
		}
		return 0;
	}
}
signed main(){return Zhchz::main();}

Submission Info

Submission Time
Task D - Paid Walk
User zhchz
Language C++23 (GCC 15.2.0)
Score 400
Code Size 4752 Byte
Status AC
Exec Time 52 ms
Memory 14888 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 57
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 2 ms 3768 KiB
example_01.txt AC 2 ms 3576 KiB
example_02.txt AC 2 ms 3924 KiB
hand_00.txt AC 37 ms 12776 KiB
hand_01.txt AC 48 ms 14264 KiB
hand_02.txt AC 43 ms 12636 KiB
hand_03.txt AC 46 ms 14224 KiB
hand_04.txt AC 42 ms 14348 KiB
hand_05.txt AC 33 ms 14608 KiB
hand_06.txt AC 4 ms 3664 KiB
hand_07.txt AC 4 ms 3612 KiB
hand_08.txt AC 41 ms 12800 KiB
hand_09.txt AC 42 ms 12800 KiB
hand_10.txt AC 2 ms 3620 KiB
hand_11.txt AC 2 ms 3872 KiB
hand_12.txt AC 33 ms 14708 KiB
hand_13.txt AC 33 ms 14572 KiB
hand_14.txt AC 29 ms 14756 KiB
hand_15.txt AC 37 ms 14880 KiB
hand_16.txt AC 42 ms 14336 KiB
hand_17.txt AC 41 ms 12776 KiB
hand_18.txt AC 41 ms 14128 KiB
hand_19.txt AC 41 ms 13696 KiB
hand_20.txt AC 41 ms 12836 KiB
hand_21.txt AC 41 ms 14184 KiB
hand_22.txt AC 41 ms 12696 KiB
hand_23.txt AC 52 ms 14368 KiB
random_00.txt AC 39 ms 13856 KiB
random_01.txt AC 38 ms 13860 KiB
random_02.txt AC 38 ms 13796 KiB
random_03.txt AC 37 ms 13532 KiB
random_04.txt AC 38 ms 13548 KiB
random_05.txt AC 38 ms 13688 KiB
random_06.txt AC 38 ms 14456 KiB
random_07.txt AC 39 ms 13348 KiB
random_08.txt AC 39 ms 13228 KiB
random_09.txt AC 38 ms 13436 KiB
random_10.txt AC 39 ms 13368 KiB
random_11.txt AC 40 ms 14888 KiB
random_12.txt AC 39 ms 14288 KiB
random_13.txt AC 42 ms 12636 KiB
random_14.txt AC 45 ms 14372 KiB
random_15.txt AC 42 ms 12780 KiB
random_16.txt AC 43 ms 12664 KiB
random_17.txt AC 52 ms 14336 KiB
random_18.txt AC 39 ms 12792 KiB
random_19.txt AC 40 ms 14244 KiB
random_20.txt AC 40 ms 12572 KiB
random_21.txt AC 38 ms 12680 KiB
random_22.txt AC 40 ms 12708 KiB
random_23.txt AC 43 ms 14336 KiB
random_24.txt AC 37 ms 13596 KiB
random_25.txt AC 37 ms 13688 KiB
random_26.txt AC 38 ms 13612 KiB
random_27.txt AC 38 ms 13668 KiB
random_28.txt AC 38 ms 13680 KiB
random_29.txt AC 37 ms 13624 KiB