제출 #1036063

#제출 시각아이디문제언어결과실행 시간메모리
1036063HNa_seawjingRobot (JOI21_ho_t4)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define fo(i,l,r) for ( int i= l ; i <= r ; i++ ) #define maxn 1000005 #define ll long long #define fi first #define se second #define mod 1000000007 using namespace std; int n , m ; int u , v , c , p ; vector<pair<int,int>> e[maxn]; vector<int>b[maxn]; map<pair<int,int>,int>d; map<pair<int,int>,int>t; int f[maxn] ; int p[maxn] ; void distra(int s) { fo(i,1,n)f[i] = 1e9 ; f[s] = 0 ; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>h; h.push({s,f[s]}); while(!h.empty()) { pair<int,int> x = h.top(); h.pop(); int u2 = x.first; if(p[u2]==1)continue ; p[u2] = 1 ; if(e[u2].size()==0)continue; fo(i,0,e[u2].size()-1) { int v2 = e[u2][i].first ; int w2 ; if(t[{u2,v2}]==1) { w2 = d[{u2,v2}]; } else w2 = 0 ; if(f[v2]>f[u2]+w2) { f[v2] = f[u2] + w2 ; h.push({v2,f[v2]}); } } } } int main() { //freopen (".inp", "r",stdin); //freopen (".out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); cin >> n >> m ; fo(i,1,m) { cin >> a[i].u >> a[i].v >> a[i].c >> a[i].p ; d[{a[i].u,a[i].v}] = a[i].p ; d[{a[i].v,a[i].u}] = a[i].p; e[a[i].u].push_back({a[i].v,a[i].c}); e[a[i].v].push_back({a[i].u,a[i].c}); } fo(i,1,n) { if(e[i].size()==0)continue; map<int,int>m; fo(j,0,e[i].size()-1) { //int v1 = e[i].first; int w = e[i][j].second ; m[w]++; } fo(j,0,e[i].size()-1) { int v1 = e[i][j].first; int w1 = e[i][j].second ; if(m[w1]>1){t[{v1,i}] = 1 ;t[{i,v1}] = 1 ;} } } distra(1); if(f[n] == 1e9)cout<<-1; else cout<<f[n]; return 0; }

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

Main.cpp:16:5: error: conflicting declaration 'int p [1000005]'
   16 | int p[maxn] ;
      |     ^
Main.cpp:10:17: note: previous declaration as 'int p'
   10 | int u , v , c , p ;
      |                 ^
Main.cpp: In function 'void distra(int)':
Main.cpp:28:13: error: invalid types 'int[int]' for array subscript
   28 |         if(p[u2]==1)continue ;
      |             ^
Main.cpp:29:10: error: invalid types 'int[int]' for array subscript
   29 |         p[u2] = 1 ;
      |          ^
Main.cpp:2:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define fo(i,l,r) for ( int i= l ; i <= r ; i++ )
......
   31 |         fo(i,0,e[u2].size()-1)
      |            ~~~~~~~~~~~~~~~~~~         
Main.cpp:31:9: note: in expansion of macro 'fo'
   31 |         fo(i,0,e[u2].size()-1)
      |         ^~
Main.cpp: In function 'int main()':
Main.cpp:60:16: error: 'a' was not declared in this scope
   60 |         cin >> a[i].u >> a[i].v >> a[i].c >>  a[i].p ;
      |                ^
Main.cpp:61:10: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>')
   61 |         d[{a[i].u,a[i].v}] = a[i].p ;
      |          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Main.cpp:62:10: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>')
   62 |         d[{a[i].v,a[i].u}] = a[i].p;
      |          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Main.cpp:2:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define fo(i,l,r) for ( int i= l ; i <= r ; i++ )
......
   70 |       fo(j,0,e[i].size()-1)
      |          ~~~~~~~~~~~~~~~~~            
Main.cpp:70:7: note: in expansion of macro 'fo'
   70 |       fo(j,0,e[i].size()-1)
      |       ^~
Main.cpp:2:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define fo(i,l,r) for ( int i= l ; i <= r ; i++ )
......
   76 |       fo(j,0,e[i].size()-1)
      |          ~~~~~~~~~~~~~~~~~            
Main.cpp:76:7: note: in expansion of macro 'fo'
   76 |       fo(j,0,e[i].size()-1)
      |       ^~