From 1dc98928428e3dd499f9fc7533fcb72bf40b3618 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Tue, 22 Oct 2024 23:00:52 +0800 Subject: [PATCH] update --- src/P1137/P1137.cpp | 41 ++++++++++++ src/P8817/P8817.cpp | 158 ++++++++++++++++++++++++++++++++++++++++++++ src/test.cpp | 77 ++------------------- 3 files changed, 204 insertions(+), 72 deletions(-) create mode 100644 src/P1137/P1137.cpp create mode 100644 src/P8817/P8817.cpp diff --git a/src/P1137/P1137.cpp b/src/P1137/P1137.cpp new file mode 100644 index 0000000..9345af3 --- /dev/null +++ b/src/P1137/P1137.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +using ll = long long; + +const ll max_n = 100000+5; +ll n, m, ans[max_n], in_degree[max_n]; +std::vector next[max_n]; +std::queue q; + +int main(){ + std::cin>>n>>m; + for(ll i{1};i<=n;i++)ans[i]=1; + for(ll i{1};i<=m;i++){ + ll a,b; + std::cin>>a>>b; + next[a].push_back(b); + in_degree[b]++; + } + for(ll i{1};i<=n;i++){ + if(in_degree[i]==0){ + q.push(i); + } + } + while(!q.empty()){ + const ll front = q.front(); + q.pop(); + for(const ll i:next[front]){ + ans[i] = std::max(ans[i],ans[front]+1); + --in_degree[i]; + if(in_degree[i]==0){ + q.push(i); + } + } + } + for(ll i{1};i<=n;i++){ + std::cout< +#include +#include +#include +#include +#include +using ll = long long; + +ll n,m,k,ans; +const ll max_n = 10000; +std::vector next[max_n]; +ll score[max_n]; +// #define ONLINE_JUDGE +#ifdef ONLINE_JUDGE + #define DEBUG(code) +#else + #define DEBUG(code)code +#endif + + +template +std::ostream &operator<<(std::ostream &os,const std::vector &t){ + os<<"vector { "; + if(t.size()>0){ + for(ll i{0};i +std::ostream &operator<<(std::ostream &os,const std::set &t){ + os<<"set { "; + auto it = t.begin(); + if(t.size()>0){ + while(*it!=*t.rbegin()){ + os<<*it++<<", "; + } + os<<*t.rbegin(); + } + os<<" }"; + return os; +} + +template +std::ostream &operator<<(std::ostream &os,const std::deque &t){ + os<<"deque { "; + for(ll i{0};i<(ll)t.size()-1;i++){ + os<vis; + DEBUG( + std::vector his; + ) + bool operator<(const State &that)const{ + return this->score>that.score; + } + friend std::ostream&operator<<(std::ostream &os, State const &s){ + os<<"State { now: "< q; +DEBUG( + State last_state; +) + + + +int main(){ + std::cin>>n>>m>>k; + for(ll i{2};i<=n;i++){ + std::cin>>score[i]; + } + for(ll i{1};i<=m;i++){ + ll u,v; + std::cin>>u>>v; + next[u].push_back(v); + next[v].push_back(u); + } + DEBUG( + std::cout< new_his {1,i}; + std::set s; + s.insert(i); + // q.push({i,1,0,score[i],DEBUG(new_his),}); + q.push({.now=i, .step=1, .used_k=0, .score=score[i], .vis=s, DEBUG(.his=new_his)}); + new_his[1] = -new_his[1]; + q.push({.now=i, .step=0, .used_k=1, .score=0, DEBUG(.his=new_his)}); + } + while(!q.empty()){ + const auto front = q.top(); + q.pop(); + DEBUG(std::cout<=k){ + continue; + } + for(const auto i:next[front.now]){ + DEBUG( + auto old_his = front.his; + old_his.push_back(-i); + ) + DEBUG( + if(front.now==3){ + std::cout< -#define NDEBUG +#include +#include -#include -#ifndef NDEBUG - #include - #include -#endif - -#define NV(v)#v<<" : "<<(v) -using ull = unsigned long long; - -#ifdef NDEBUG - #define ARR_NDB_NOEXCEPT noexcept - #define ARR_NDB_CONSTEXPR constexpr -#else - #define ARR_NDB_CONSTEXPR - #define ARR_NDB_NOEXCEPT -#endif - -template -constexpr bool test(){ - return a>=b; +bool cmp(const int a,const int b){ + return a>b; } -template -class Array{ -public: -private: - T arr[size]; -public: - ARR_NDB_CONSTEXPR T& operator[](const size_t n)ARR_NDB_NOEXCEPT{ - #ifndef NDEBUG - if(n>=size){ - std::stringstream ss; - ss<<"\nYour [array size] is: "<=size){ - std::stringstream ss; - ss<<"\nYour [array size] is: "< arr{}; -ull a; - int main(){ - std::cout<,std::less> q; } \ No newline at end of file