제출 #896554

#제출 시각아이디문제언어결과실행 시간메모리
896554AgentPenginJakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
/** * author: AgentPengin ( Độc cô cầu bại ) * created: 23.12.2022 10:08:02 * too lazy to update time **/ #include<bits/stdc++.h> #define EL '\n' #define fi first #define se second #define NAME "TASK" #define ll long long #define lcm(a,b) (a/gcd(a,b))*b #define db(val) "["#val" = " << (val) << "] " #define bend(v) (v).begin(),(v).end() #define sz(v) (int)(v).size() #define ex exit(0) using namespace std; const ll mod = 1e9 + 7; const int inf = 0x1FFFFFFF; const int MAXN = 30005; int n,m,pw[MAXN],pos[MAXN]; vector<int> adj[MAXN]; bitset<MAXN> visit[MAXN]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if (ifstream(NAME".inp")) { freopen(NAME".inp","r",stdin); freopen(NAME".out","w",stdout); } cin >> n >> m; for (int i = 1;i <= m;i++) { cin >> pos[i] >> pw[i]; adj[pos[i]].push_back(pw[i]); } queue<tuple<int,int,int>> q; q.push({pos[1],pw[1],0}); int ans = -1; while(!q.empty()) { int u,p,d; tie(u,p,d) = q.front(); q.pop(); if (u == pos[2]) { ans = d; break; } if (u - p >= 0 && !visit[u - p][p]) { visit[u - p][p] = 1; q.push({u - p,p, d + 1}); } if (u + p < n && !visit[u + p][p]) { visit[u + p][p] = 1; q.push({u + p,p,d + 1}); } for (int p : adj[u]) { visit[u][p] = 1; if (u - p >= 0 && !visit[u - p][p]) { visit[u - p][p] = 1; q.push({u - p,p,d + 1}); } if (u + p < n && !visit[u + p][p]) { visit[u + p][p] = 1; q.push({u + p,p,d + 1}); } } } cout << ans; cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; } // agent pengin wants to take apio (with anya-san)

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:53:25: error: reference to 'visit' is ambiguous
   53 |      if (u - p >= 0 && !visit[u - p][p]) {
      |                         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:54:7: error: reference to 'visit' is ambiguous
   54 |       visit[u - p][p] = 1;
      |       ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:57:24: error: reference to 'visit' is ambiguous
   57 |      if (u + p < n && !visit[u + p][p]) {
      |                        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:58:7: error: reference to 'visit' is ambiguous
   58 |       visit[u + p][p] = 1;
      |       ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:62:7: error: reference to 'visit' is ambiguous
   62 |       visit[u][p] = 1;
      |       ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:63:26: error: reference to 'visit' is ambiguous
   63 |       if (u - p >= 0 && !visit[u - p][p]) {
      |                          ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:64:8: error: reference to 'visit' is ambiguous
   64 |        visit[u - p][p] = 1;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:67:25: error: reference to 'visit' is ambiguous
   67 |       if (u + p < n && !visit[u + p][p]) {
      |                         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:68:8: error: reference to 'visit' is ambiguous
   68 |        visit[u + p][p] = 1;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from skyscraper.cpp:6:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
skyscraper.cpp:27:14: note:                 'std::bitset<30005> visit [30005]'
   27 | bitset<MAXN> visit[MAXN];
      |              ^~~~~
skyscraper.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~