제출 #334945

#제출 시각아이디문제언어결과실행 시간메모리
334945SaynaaJakarta Skyscrapers (APIO15_skyscraper)C++14
57 / 100
1076 ms9704 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(){ scanf("%d%d", &n, &m); for(int i = 0; i < m; i ++){ scanf("%d%d", &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(); 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, 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, q.push({-dis[i], i}); x ++; } } } printf("%d\n", (dis[b[1]] != INT_MAX/2 ? dis[b[1]] : -1 )); return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int i = 0; i < adj[v].size(); i ++){
      |                  ~~^~~~~~~~~~~~~~~
skyscraper.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
skyscraper.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |   scanf("%d%d", &b[i], &p[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...