제출 #882568

#제출 시각아이디문제언어결과실행 시간메모리
882568vjudge1Jakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
1024 ms7900 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC targe("avx2,bmi,bmi2,sse4.2") #include <bits/stdc++.h> using namespace std; #define int int64_t const int MAXM = 3e5+5; int n, p[MAXM], B[MAXM], m; struct quad { int first, second, third, fourth; quad() : first(0), second(0), third(0), fourth(0) {} quad(int a, int b, int c, int d) :first(a), second(b), third(c), fourth(d) {} }; signed main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 0; i < m; i++) cin >> B[i] >> p[i]; vector<int> a(n, INT64_MAX); vector<vector<int>> b(n); stack<quad> curr, oth; curr.push({0, B[0], p[0], 3}); for(int i = 0; i < m; i++) b[B[i]].push_back(i); while(!(curr.empty() && oth.empty())) { auto cur = curr.top(); curr.pop(); if(a[cur.second] == INT64_MAX) { for(auto x:b[cur.second]) if(p[x] != cur.third) curr.push({cur.first, cur.second, p[x], 3}); } a[cur.second] = min(a[cur.second], cur.first); if(cur.second >= cur.third && cur.fourth != 2) oth.push({cur.first + 1, cur.second - cur.third, cur.third, 1}); if(cur.second < n - cur.third && cur.fourth != 1) oth.push({cur.first + 1, cur.second + cur.third, cur.third, 2}); if(curr.empty()) swap(curr, oth); } cout << (a[B[1]] == INT64_MAX ? -1 : a[B[1]]) << '\n'; }

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

skyscraper.cpp:2: warning: ignoring '#pragma GCC targe' [-Wunknown-pragmas]
    2 | #pragma GCC targe("avx2,bmi,bmi2,sse4.2")
      |
#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...