제출 #472048

#제출 시각아이디문제언어결과실행 시간메모리
472048hhhhauraJakarta Skyscrapers (APIO15_skyscraper)C++14
22 / 100
176 ms262148 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i --) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 1000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { const int P = 5000000; const int K = 140; int n, m, st, ed, ii; vector<int> dis, s; vector<vector<int>> mp1, mp0; vector<vector<vector<int>>> a; void init_(int _n, int _m) { n = _n, m = _m, ii = n - 1; s.clear(); dis.assign(P, INF); mp1.assign(P, vector<int>()); mp0.assign(P, vector<int>()); rep(i, 0, K - 1) a.push_back(vector<vector<int>>(i, vector<int>())); } void get_new() { ii++; if(ii >= P) exit(0); } void add_node(int pos, int b) { for(int i = pos % b; i < n; i += b) { get_new(); if(i == pos) mp0[i].push_back(ii); if(i != pos % b) { mp1[ii].push_back(ii - 1); mp1[ii - 1].push_back(ii); } mp0[ii].push_back(i); } } int solve() { rep(i, 1, K - 1) rep(j, 0, i - 1) { if(!a[i][j].size()) continue; sort(all(a[i][j])); vector<int> &v = a[i][j]; int id = -1; for(int k = j; k < n; k += i) { get_new(); while(id + 1 < v.size() && v[id + 1] <= k) id ++; if(id >= 0 && v[id] == k) mp0[k].push_back(ii); if(k != j) { mp1[ii].push_back(ii - 1); mp1[ii - 1].push_back(ii); } mp0[ii].push_back(k); } } dis[st] = 0; deque<int> q; q.push_back(st); while(q.size()) { int cur = q.front(); q.pop_front(); for(auto i : mp0[cur]) if(dis[i] == INF) { dis[i] = dis[cur]; q.push_front(i); } for(auto i : mp1[cur]) if(dis[i] == INF) { dis[i] = 1 + dis[cur]; q.push_back(i); } } return (dis[ed] == INF ? -1 : dis[ed]); } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n, m, b, p; cin >> n >> m; init_(n, m); rep(i, 0, m - 1) { cin >> b >> p; if(i == 0) st = b; if(i == 1) ed = b; if(p >= K) add_node(b, p); else a[p][b % p].push_back(b); } cout << solve() << "\n"; return 0; }

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

skyscraper.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
skyscraper.cpp:23:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   23 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
skyscraper.cpp:23:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   23 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
skyscraper.cpp: In function 'int solver::solve()':
skyscraper.cpp:69:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     while(id + 1 < v.size() && v[id + 1] <= k) id ++;
      |           ~~~~~~~^~~~~~~~~~
#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...