제출 #683913

#제출 시각아이디문제언어결과실행 시간메모리
683913speedyArdaJakarta Skyscrapers (APIO15_skyscraper)C++14
22 / 100
821 ms262144 KiB
#include "bits/stdc++.h" using namespace std; const int MAXN = 3e4+5; vector<set< pair<int, int> > > adj(MAXN); vector< set < int > > doges(MAXN); int dp[MAXN]; map< pair<int, int>, bool > done; map< pair<int, int>, int> max_road; bool visited[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int goal, begin; for(int i = 0; i < m; i++) { pair<int, int> temp; cin >> temp.first >> temp.second; if(i == 1) goal = temp.first; else if(i == 0) begin = temp.first; doges[temp.first].insert(temp.second); int curr = temp.first + temp.second; int cnt = 1; while(curr < n) { int val = max_road[{temp.first, curr}]; if(val == 0 || val > cnt) { adj[temp.first].erase({val, curr}); max_road[{temp.first, curr}] = cnt; adj[temp.first].insert({cnt, curr}); } //if(curr == 4) //cout << temp.first << "\n"; cnt++; curr += temp.second; } curr = temp.first - temp.second; cnt = 1; while(curr >= 0) { int val = max_road[{temp.first, curr}]; if(val == 0 || val > cnt) { adj[temp.first].erase({val, curr}); max_road[{temp.first, curr}] = cnt; adj[temp.first].insert({cnt, curr}); } //if(curr == 1) //cout << temp.first << "\n"; cnt++; curr -= temp.second; } } for(int i = 0; i <= n; i++) { dp[i] = 1e9; visited[i] = false; } visited[begin] = false; dp[begin] = 0; set< pair<int, int> > curr; curr.insert({0, begin}); int ans = 1e9; while(!curr.empty()) { pair<int, int> temp = *(curr.begin()); int v = temp.second; int len = temp.first; //cout << v << "\n"; curr.erase(curr.begin()); // if(v == goal) // ans = min(ans, ) for(pair<int, int> e : adj[v]) { //cout << v << " " << e.second << "\n"; if(dp[e.second] > len + e.first) { curr.erase({dp[e.second], e.second}); dp[e.second] = len + e.first; curr.insert({dp[e.second], e.second}); } } //adj[v].clear(); //cout << v << "\n"; //dp[v] = 1e9; } ans = dp[goal]; if(ans >= 1e9) ans = -1; cout << ans << "\n"; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:99:9: warning: 'goal' may be used uninitialized in this function [-Wmaybe-uninitialized]
   99 |     ans = dp[goal];
      |     ~~~~^~~~~~~~~~
#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...