제출 #402534

#제출 시각아이디문제언어결과실행 시간메모리
402534faresbasbsJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
2 ms1028 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; bitset<30001> bs,bs2[30001]; vector<int> v[30001]; int n,m; int main(){ ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); cin >> n >> m; for(int i = 0 ; i < m ; i += 1){ int a,b; cin >> a >> b; v[a].push_back(b); } queue<pair<int,int>> q; q.push({0,0}); int dist = 0; while(q.size()){ int f = q.size(); queue<pair<int,int>> q2; while(q.size()){ pair<int,int> a = q.front(); q.pop(); if(!bs[a.first]){ bs[a.first] = 1; for(auto i : v[a.first]){ q.push({a.first,i}) , bs2[a.first][i] = 1; } } if(a.first+a.second < n && !bs2[a.first+a.second][a.second]){ q2.push({a.first+a.second,a.second}) , bs2[a.first+a.second][a.second] = 1; } if(a.first-a.second >= 0 && !bs2[a.first-a.second][a.second]){ q2.push({a.first-a.second,a.second}) , bs2[a.first-a.second][a.second] = 1; } } q = q2; if(bs[1]){ cout << dist << '\n'; return 0; } dist += 1; } cout << -1 << endl; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:22:7: warning: unused variable 'f' [-Wunused-variable]
   22 |   int f = q.size();
      |       ^
#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...