제출 #170908

#제출 시각아이디문제언어결과실행 시간메모리
170908ne4eHbKaJakarta Skyscrapers (APIO15_skyscraper)C++17
0 / 100
3 ms1144 KiB
//{ <defines> #ifndef _LOCAL #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") #endif #include <bits/stdc++.h> using namespace std; #define fr(i, n) for(int i = 0; i < n; ++i) #define fo(n) fr(i, n) #define re return #define ef else if #define ifn(x) if(!(x)) #define _ << ' ' << #define ft first #define sd second #define ve vector #define pb push_back #define eb emplace_back #define sz(x) int(x.size()) #define pw(x) (1 << (x)) #define PW(x) (1ll << (x)) #define bnd(x) x.begin(), x.end() #define clr(x, y) memset(x, y, sizeof x) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef ve<int> vi; const int oo = 2e9; const ll OO = 4e18; //const ld pi = arg(complex<ld>(-1, 0)); //const ld pi2 = pi + pi; const int md = 0x3b800001; const int MD = 1e9 + 7; inline ll time() {re chrono :: system_clock().now().time_since_epoch().count();} mt19937 rnd(time()); mt19937_64 RND(time()); template<typename t> inline void umin(t &a, t b) {a = min(a, b);} template<typename t> inline void umax(t &a, t b) {a = max(a, b);} //} </defines> const int N = 3e4 + 5; int n, m, st, fn, d[N]; vi g[N]; bool mk[N]; void solve() { cin >> n >> m; fo(m) { int b, p; cin >> b >> p; if(i == 0) st = b; if(i == 1) fn = b; g[b].pb(p); } fo(n) d[i] = N; d[st] = 0; struct sc { inline bool operator() (const int &a, const int &b) {re d[a] == d[b] ? a < b : d[b] < d[b];} }; set<int, sc> f; f.insert(st); for(; !f.empty(); ) { int v = *f.begin(); f.erase(f.begin()); mk[v] = 1; if(v == fn) re void(cout << d[fn] << endl); for(int p : g[v]) { for(int sign = -1; sign <= 1; sign += 2) { for(int w = 1, u = v + sign * p; u >= 0 && u < n; ++w, u += sign * p) { if(mk[u]) continue; int dd = d[v] + w; if(dd < d[u]) { auto c = f.find(u); if(c != f.end()) f.erase(c); d[u] = dd; f.insert(u); } } } } } cout << -1 << endl; } int main() { #ifdef _LOCAL freopen("in.txt", "r", stdin); #endif solve(); }

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

skyscraper.cpp: In member function 'bool solve()::sc::operator()(const int&, const int&)':
skyscraper.cpp:72:45: warning: self-comparison always evaluates to false [-Wtautological-compare]
             {re d[a] == d[b] ? a < b : d[b] < d[b];}
                                        ~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...