diff --git a/src/20241111/U101804.cpp b/src/20241111/U101804.cpp index e7b85f7..d562602 100644 --- a/src/20241111/U101804.cpp +++ b/src/20241111/U101804.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -27,9 +28,47 @@ func print(Args...args){ } const i64 max_n = 100000 + 5, mod{998244353}; -i64 w[max_n], a[max_n]; +i64 w[max_n], a[max_n], dfs_in[max_n], dfs_out[max_n]; std::vector sons[max_n]; +template +class Segtree{ +private: + std::array nodes{}; + std::array lazy_mul; + void build(const i64 (&arr)[], const i64 l, const i64 r, const i64 n){ + if(l==r){ + nodes[n]=arr[l]; + return; + } + + const i64 mid {(l+r)/2}; + build(arr, l, mid, n*2); + build(arr, mid+1, r, n*2+1); + + nodes[n] = nodes[n*2] + nodes[n*2+1]; + } + + void update_mul(const i64 ul, const i64 ur, const i64 l, const i64 r,const i64 n){ + if(lazy_mul[n]!=1){ + // nodes[] + } + + if(r < ul || ur < l){ + return; + } + } +public: + Segtree(const i64 (&arr)[], const i64 n){ + build(arr, 1, n, 1); + std::fill(lazy_mul.begin(), lazy_mul.end(), 1); + } + +}; + +//testing +Segtree<50> st(a,2); + i64 mod_pow(i64 b, i64 e, const i64 m = mod){ b %= mod; i64 res {1}; diff --git a/src/20241113/T538693.cpp b/src/20241113/T538693.cpp new file mode 100644 index 0000000..99494e8 --- /dev/null +++ b/src/20241113/T538693.cpp @@ -0,0 +1,105 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using int64 = std::int64_t; + +template +void input(Args&&...args){ + (std::cin>>...>>std::forward(args)); +} + +template +std::remove_cv_t input(){ + std::remove_cv_t t; + std::cin>>t; + return t; +} + +template +void print(Args&&...args){ + (std::cout<<...<x + this->y) < (that.x + that.y); + } + bool operator==(const Point &that)const{ + return this->x == that.x && this->y == that.y; + } +}; + +using Vector2 = Point; +using Status = std::pair; + +const int64 max_n = 100 + 5; +int64 _map[max_n][max_n]; +const int64 (&map)[max_n][max_n] = _map; +const std::array, 4> dir{{ + {0, 1}, + {1, 0}, + {-1, 0}, + {0, -1} +}}; + +int main(){ + std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr); + std::cout<(), m = input(); + + const auto inputPoint = []()->Point{ + Point ret; + input(ret.x, ret.y); + return ret; + }; + const Point start = inputPoint(), end = inputPoint(); + + std::ranges::for_each(std::ranges::views::iota(1, n+1), [&](const auto &i){ + std::ranges::for_each(std::ranges::views::iota(1,m+1), [&](const auto &j){ + input(_map[n][m]); + }); + }); + + const double ansScore = input(); + + std::priority_queue, std::greater<>> pq; + pq.emplace(Vector2{0, 0}, start); + + const Vector2 ansVec = [&]()->Vector2{ + while(!pq.empty()){ + const auto top = pq.top(); + pq.pop(); + + if(top.second == end){ + return top.first; + } + + for (const auto i : dir) { + const Point nextPoint = {top.second.x + i[0], top.second.y + i[1]}; + if(map[nextPoint.x][nextPoint.y] == 1 || nextPoint.x < 1 || nextPoint.x > n || nextPoint.y < 1 || nextPoint.y > m){ + continue; + } + pq.emplace(Vector2{.x = top.first.x + std::abs(i[0]), .y = top.first.y + std::abs(i[1])}, nextPoint); + } + } + throw std::runtime_error("unreachable"); + }(); + + const double udTimes = ansScore - (double)ansVec.x; + print(udTimes/ansVec.y); +} \ No newline at end of file