Submission #95538

#TimeUsernameProblemLanguageResultExecution timeMemory
95538MohamedAhmed0Jakarta Skyscrapers (APIO15_skyscraper)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010 , MAXM = 30010; int visited[MAX] ; pair<int , int>arr[MAXM] ; 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(!visited[j]) q.push({dist + cnt , j}); } cnt = 0 ; for(int j = idx - arr[i].second ; j >= 0 ; j -= arr[i].second) { cnt++; if(!visited[j]) q.push({dist + cnt , j}); } } } return cout<<-1<<"\n" , 0 ; }

Compilation message (stderr)

skyscraper.cpp:6:13: error: 'MAX' was not declared in this scope
 int visited[MAX] ;
             ^~~
skyscraper.cpp:6:13: note: suggested alternative: 'MAXM'
 int visited[MAX] ;
             ^~~
             MAXM
skyscraper.cpp:8:26: error: 'MAX' was not declared in this scope
 vector< vector<int> >now(MAX) ;
                          ^~~
skyscraper.cpp:8:26: note: suggested alternative: 'MAXM'
 vector< vector<int> >now(MAX) ;
                          ^~~
                          MAXM
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:28:12: error: 'visited' was not declared in this scope
         if(visited[idx])
            ^~~~~~~
skyscraper.cpp:28:12: note: suggested alternative: 'finitel'
         if(visited[idx])
            ^~~~~~~
            finitel
skyscraper.cpp:30:9: error: 'visited' was not declared in this scope
         visited[idx] = 1 ;
         ^~~~~~~
skyscraper.cpp:30:9: note: suggested alternative: 'finitel'
         visited[idx] = 1 ;
         ^~~~~~~
         finitel