제출 #334952

#제출 시각아이디문제언어결과실행 시간메모리
334952SaynaaJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
7 ms7436 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e5 + 2; int n, m, b[MAXN], p[MAXN], dis[MAXN]; vector< int > adj[MAXN]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 0; i < m; i ++){ cin >> b[i] >> p[i]; adj[b[i]].push_back(p[i]); } fill(dis, dis + n, INT_MAX/2); dis[b[0]] = 0; priority_queue< pair< int, int> > q; q.push({0, b[0]}); while( q.size() ){ int v = q.top().second; q.pop(); if(dis[v] == INT_MAX) break; for(int i = 0; i < adj[v].size(); i ++){ int u = adj[v][i]; int x = 1; for(int i = v + u; i < n; i += u){ if( dis[i] <= dis[v] + x){ x ++; continue; } dis[i] = dis[v] + x; if( i != b[1]) q.push({-dis[i], i}); x ++; } x = 1; for(int i = v - u; i >= 0; i -= u){ if( dis[i] <= dis[v] + x){ x ++; continue; } dis[i] = dis[v] + x; if( i != b[1]) q.push({-dis[i], i}); x ++; } } } if( dis[b[1]] != INT_MAX) return printf("%d", dis[b[1]]), 0; printf("%d",-1); return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i = 0; i < adj[v].size(); i ++){
      |                  ~~^~~~~~~~~~~~~~~
#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...