제출 #437626

#제출 시각아이디문제언어결과실행 시간메모리
437626yiqilim5438던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include"dungeons.h" using namespace std; typedef long long ll; typedef pair<ll,ll> pll; int n; vector<ll>s,p,w,l; vector<ll>ws(5e4+5,0ll); vector<vector<pll>>ls(1005,vector<pll>(5e4+5)); void init(int N,vector<ll>S,vector<ll>P,vector<ll>W,vector<ll>L){ n = N,s = S,p = P,w = W,l = L; for(int i = n-1;i>=0;i--){ ws[i] = s[i]+s[w[i]]; } for(int i = 0;i<n;i++){ int x = i; for(int j = 1;j<=1000;j++){ ls[i][j].first = ls[i][j-1].first+p[x]; x = l[x]; ls[i][j].second = x; } } }; ll simulate(int x,int z){ if(z>=s[x]){ return z+ws[x]; } else{ if(z+ls[x][1000].first>=s[x]){ while(true){ if(z>=s[x]) return z+ws[x]; else z += p[x]; x = l[x]; } } else{ z += ls[x][1000].first; x = ls[x][1000].second; simulate(x,z); } } }

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

dungeons.cpp: In function 'void init(int, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
dungeons.cpp:13:12: error: reference to 'ws' is ambiguous
   13 |            ws[i] = s[i]+s[w[i]];
      |            ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
dungeons.cpp:8:11: note:                 'std::vector<long long int> ws'
    8 | vector<ll>ws(5e4+5,0ll);
      |           ^~
dungeons.cpp: In function 'll simulate(int, int)':
dungeons.cpp:27:18: error: reference to 'ws' is ambiguous
   27 |         return z+ws[x];
      |                  ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
dungeons.cpp:8:11: note:                 'std::vector<long long int> ws'
    8 | vector<ll>ws(5e4+5,0ll);
      |           ^~
dungeons.cpp:32:38: error: reference to 'ws' is ambiguous
   32 |                 if(z>=s[x]) return z+ws[x];
      |                                      ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
dungeons.cpp:8:11: note:                 'std::vector<long long int> ws'
    8 | vector<ll>ws(5e4+5,0ll);
      |           ^~