Submission #95535

#TimeUsernameProblemLanguageResultExecution timeMemory
95535MohamedAhmed0Jakarta Skyscrapers (APIO15_skyscraper)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 2010 ; int visited[MAX] ; pair<int , int>arr[MAX] ; vector< vector<int> >now(MAX) ; int main() { int n , m ; cin>>n>>m ; for(int i = 0 ; i < m ; ++i) { cin>>arr[i].first>>arr[i].second; now[arr[i].first].push_back(i); } priority_queue< pair<int , int> , vector< pair<int , int> > , greater< pair<int , int> > >q ; q.push({0 , arr[0].first}); while(!q.empty()) { pair<int , int>p = q.top() ; q.pop() ; int dist = p.first , idx = p.second ; if(idx == arr[1].first) return cout<<dist<<"\n" , 0 ; if(visited[idx]) continue; visited[idx] = 1 ; for(auto &i : now[idx]) { int cnt = 0 ; for(int j = idx+arr[i].second ; j < n ; j += arr[i].second) { cnt++ ; if(!vis[j]) q.push({dist + cnt , j}); } cnt = 0 ; for(int j = idx - arr[i].second ; j >= 0 ; j -= arr[i].second) { cnt++; if(!vis[j]) q.push({dist + cnt , j}); } } } return cout<<-1<<"\n" , 0 ; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:37:21: error: 'vis' was not declared in this scope
                 if(!vis[j])
                     ^~~
skyscraper.cpp:37:21: note: suggested alternative: 'dist'
                 if(!vis[j])
                     ^~~
                     dist
skyscraper.cpp:44:21: error: 'vis' was not declared in this scope
                 if(!vis[j])
                     ^~~
skyscraper.cpp:44:21: note: suggested alternative: 'dist'
                 if(!vis[j])
                     ^~~
                     dist