제출 #882577

#제출 시각아이디문제언어결과실행 시간메모리
882577vjudge1Jakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
1040 ms2396 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC targe("avx2,bmi,bmi2,sse4.2") #include <bits/stdc++.h> using namespace std; const int MAXM = 3e4+5, MAXN = 3e4+5; int n, p[MAXM], B[MAXM], m, a[MAXN]; struct triple { int first, second, third; triple() : first(0), second(0), third(0) {} triple(int a, int b, int c) :first(a), second(b), third(c) {} }; signed main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 0; i < m; i++) cin >> B[i] >> p[i]; for(int i = 0; i < n; i++) a[i] = INT_MAX; vector<vector<int>> b(n); stack<triple> curr, oth; curr.push({B[0], p[0], 3}); for(int i = 0; i < m; i++) b[B[i]].push_back(i); int curval = 0; while(!(curr.empty() && oth.empty())) { auto cur = curr.top(); curr.pop(); if(a[cur.first] == INT_MAX) for(auto x:b[cur.first]) if(p[x] != cur.second) curr.push({cur.first, p[x], 3}); a[cur.first] = min(a[cur.first], curval); if(cur.first >= cur.second && cur.third != 2) oth.push({cur.first - cur.second, cur.second, 1}); if(cur.first < n - cur.second && cur.third != 1) oth.push({cur.first + cur.second, cur.second, 2}); if(curr.empty()) { swap(curr, oth); curval ++; } } cout << (a[B[1]] == INT_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...