제출 #238139

#제출 시각아이디문제언어결과실행 시간메모리
238139MercenaryJakarta Skyscrapers (APIO15_skyscraper)C++14
22 / 100
9 ms3456 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "SKY" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 5e4 + 5; const int mod = 1e9 + 7; int dis[maxn] , n , m; unordered_set<int> s[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n >> m; int ft = 0 , lt = 0; for(int i = 0 ; i < m ; ++i){ int u ,v;cin >> u >> v;s[u].insert(v); if(i == 0)ft = u; if(i == 1)lt = u; } priority_queue<ii , vector<ii> , greater<ii> > pq; fill_n(dis,maxn,1e9); dis[ft] = 0;pq.push(mp(0,ft)); while(pq.size()){ auto u = pq.top();pq.pop(); if(dis[u.second] != u.first)continue; for(auto &c : s[u.second]){ int cnt = 0; for(int i = u.second + c ; i < n ; i += c){ cnt++; if(u.first + cnt < dis[i]){ dis[i] = u.first + cnt;pq.push(mp(dis[i],i)); } if(s[i].count(c))break; } cnt = 0; for(int i = u.second - c ; i > 0 ; i -= c){ cnt++; if(u.first + cnt < dis[i]){ dis[i] = u.first + cnt;pq.push(mp(dis[i],i)); } if(s[i].count(c))break; } } } if(dis[lt] == 1e9)cout << -1; else cout << dis[lt]; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...