제출 #398266

#제출 시각아이디문제언어결과실행 시간메모리
398266juggernautJakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif typedef pair<int,int> data; data a[30010]; int st[30010],D[30010]; priority_queue<data,vector<data>,greater<data> > q; int main(){ int i,j,n,m,s,e,d; scanf("%d%d",&n,&m); for(i=0;i<m;++i)scanf("%d%d",&a[i].f,&a[i].s); s=a[0].f,e=a[1].f; sort(a,a+m); st[a[0].f]=0; for(i=1;i<m;++i)if(a[i].f!=a[i-1].f)st[a[i].f]=i; for(i=0;i<n;++i)D[i]=2e9; D[s]=0; q.push({0,s}); while(!q.empty()){ data p=q.top(); q.pop(); if(D[p.s]!=p.f)continue; for(i=st[p.s];a[i].f==p.s&&i<m;++i){ d=p.f; for(j=p.s+a[i].s;j<n;j+=a[i].s)if(D[j]>++d)q.push({D[j]=d,j}); d=p.f; for(j=p.s-a[i].s;j>=0;j-=a[i].s)if(D[j]>++d)q.push({D[j]=d,j}); } } printf("%d",D[e]<2e9?D[e]:-1); return 0; }

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

skyscraper.cpp:21:1: error: reference to 'data' is ambiguous
   21 | data a[30010];
      | ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from skyscraper.cpp:1:
/usr/include/c++/9/bits/range_access.h:318:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  318 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:309:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  309 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:299:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  299 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:289:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  289 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
skyscraper.cpp:20:23: note:                 'typedef struct std::pair<int, int> data'
   20 | typedef pair<int,int> data;
      |                       ^~~~
skyscraper.cpp:23:32: error: template argument 1 is invalid
   23 | priority_queue<data,vector<data>,greater<data> > q;
      |                                ^
skyscraper.cpp:23:32: error: template argument 2 is invalid
skyscraper.cpp:23:46: error: template argument 1 is invalid
   23 | priority_queue<data,vector<data>,greater<data> > q;
      |                                              ^
skyscraper.cpp:23:48: error: template argument 1 is invalid
   23 | priority_queue<data,vector<data>,greater<data> > q;
      |                                                ^
skyscraper.cpp:23:48: error: template argument 2 is invalid
skyscraper.cpp:23:48: error: template argument 3 is invalid
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:27:35: error: 'a' was not declared in this scope
   27 |     for(i=0;i<m;++i)scanf("%d%d",&a[i].f,&a[i].s);
      |                                   ^
skyscraper.cpp:28:7: error: 'a' was not declared in this scope
   28 |     s=a[0].f,e=a[1].f;
      |       ^
skyscraper.cpp:34:7: error: request for member 'push' in 'q', which is of non-class type 'int'
   34 |     q.push({0,s});
      |       ^~~~
skyscraper.cpp:35:14: error: request for member 'empty' in 'q', which is of non-class type 'int'
   35 |     while(!q.empty()){
      |              ^~~~~
skyscraper.cpp:36:9: error: reference to 'data' is ambiguous
   36 |         data p=q.top();
      |         ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from skyscraper.cpp:1:
/usr/include/c++/9/bits/range_access.h:318:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  318 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:309:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  309 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:299:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  299 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:289:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  289 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
skyscraper.cpp:20:23: note:                 'typedef struct std::pair<int, int> data'
   20 | typedef pair<int,int> data;
      |                       ^~~~
skyscraper.cpp:37:11: error: request for member 'pop' in 'q', which is of non-class type 'int'
   37 |         q.pop();
      |           ^~~
skyscraper.cpp:38:14: error: 'p' was not declared in this scope
   38 |         if(D[p.s]!=p.f)continue;
      |              ^
skyscraper.cpp:39:18: error: 'p' was not declared in this scope
   39 |         for(i=st[p.s];a[i].f==p.s&&i<m;++i){
      |                  ^
skyscraper.cpp:41:58: error: request for member 'push' in 'q', which is of non-class type 'int'
   41 |             for(j=p.s+a[i].s;j<n;j+=a[i].s)if(D[j]>++d)q.push({D[j]=d,j});
      |                                                          ^~~~
skyscraper.cpp:43:59: error: request for member 'push' in 'q', which is of non-class type 'int'
   43 |             for(j=p.s-a[i].s;j>=0;j-=a[i].s)if(D[j]>++d)q.push({D[j]=d,j});
      |                                                           ^~~~
skyscraper.cpp: In function 'void usaco(std::string)':
skyscraper.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~