제출 #971034

#제출 시각아이디문제언어결과실행 시간메모리
971034aryanc403Finding Routers (IOI20_routers)C++17
100 / 100
5 ms860 KiB
/* Compete against Yourself. Author - Aryan (@aryanc403) */ /* Credits - Atcoder library - https://atcoder.github.io/ac-library/production/document_en/ (namespace atcoder) Github source code of library - https://github.com/atcoder/ac-library/tree/master/atcoder https://codeforces.com/contest/4/submission/150120627 */ #include "routers.h" #ifdef ARYANC403 #include <header.h> #else #pragma GCC optimize ("Ofast") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") // #pragma GCC target ("sse,sse2,mmx") #pragma GCC optimize ("-ffloat-store") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define dbg(args...) 42; #define endl "\n" #endif // y_combinator from @neal template https://codeforces.com/contest/1553/submission/123849801 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html template<class Fun> class y_combinator_result { Fun fun_; public: template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {} template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } using namespace std; #define fo(i,n) for(i=0;i<(n);++i) #define repA(i,j,n) for(i=(j);i<=(n);++i) #define repD(i,j,n) for(i=(j);i>=(n);--i) #define all(x) begin(x), end(x) #define sz(x) ((lli)(x).size()) #define eb emplace_back #define X first #define Y second using lli = long long int; using mytype = long double; using ii = pair<lli,lli>; using vii = vector<ii>; using vi = vector<lli>; template <class T> using ordered_set = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; std::vector<int> find_routers(int l, int n, int q) { std::vector<int> ans(n); map<lli,lli> dp; auto getVal=[&](const lli L)->lli{ if(dp.count(L)) return dp[L]; auto it=dp.lower_bound(L); auto jt=it; if(jt!=dp.begin()&&it!=dp.end()){ --jt; if(jt->Y==it->Y) return it->Y; } const lli h = use_detector(L); return dp[L]=h; }; y_combinator([&](const auto &self,const lli l,const lli r)->void{ if(getVal(l)==getVal(r)) return; if(r-l<2) return; const lli m=(l+r)/2; self(l,m); self(m,r); })(0,l); dbg(dp); std::vector<lli> mids(n,l); for(const auto &x:dp) mids[x.Y]=min(mids[x.Y],x.X); for (int i = 1; i < n; i++) { const int mid = mids[i]-1; ans[i]=2*mid-ans[i-1]; } return ans; }

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

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:23:26: warning: statement has no effect [-Wunused-value]
   23 |     #define dbg(args...) 42;
      |                          ^~
routers.cpp:85:5: note: in expansion of macro 'dbg'
   85 |     dbg(dp);
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...