제출 #438268

#제출 시각아이디문제언어결과실행 시간메모리
438268PiejanVDC던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; int nnn; vector<int>sss,ppp,www,lll; vector<long long>winning_path; //vector<int>adj[400001]; void gen(void); void init(int nn, vector<int> ss, vector<int> pp, vector<int> ww, vector<int> ll) { nnn=nn; sss=ss,ppp=pp,www=ww,lll=ll; /*for(int i = 0 ; i < nnn ; i++) { adj[www[i]].push_back(i); }*/ gen(); } void gen(void) { vector<bool>vis(nnn+1,false); winning_path.resize(nnn+1); winning_path[nnn]=0; for(int i = 0 ; i < nnn ; i++) { next=i; long long cnt=0; while(next!=nnn) { cnt++; next=www[next]; } winning_path[i]=cnt; } } long long simulate(int x, int zz) { vector<pair<bool,long long>>v(nnn+1,{false,0}); vector<long long> seq; long long curr=0, len=0; long long z=zz; while(true) { if(v[x].first) { long long ans = (sss[x]-z)/(curr-v[x].second); z+=ans*(curr-v[x].second); int left=0, right=seq.size()-1, use=x; while(left <= right) { int mid = (left+right)/2; if(z+(v[seq[mid]].second-v[x].second) >= sss[x]) { use=mid; right=mid-1; } else { left=mid+1; } } if(use>0&&use<seq.size()){ z+=v[seq[use]].second - v[x].second; x=seq[use]; } } if(x==nnn) return z; if(z >= sss[x]) { long long mul = sss[x]*winning_path[x]; return z+mul; } v[x].first=true,v[x].second=curr; z+=ppp[x], curr+=ppp[x]; seq.push_back(x); x=lll[x]; len++; } }

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

dungeons.cpp: In function 'void gen()':
dungeons.cpp:27:14: error: overloaded function with no contextual type information
   27 |         next=i;
      |              ^
dungeons.cpp:29:19: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator!='
   29 |         while(next!=nnn) {
      |               ~~~~^~~~~
dungeons.cpp:31:21: error: no match for 'operator[]' (operand types are 'std::vector<int>' and '<unresolved overloaded function type>')
   31 |             next=www[next];
      |                     ^
In file included from /usr/include/c++/10/vector:67,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             if(use>0&&use<seq.size()){
      |                       ~~~^~~~~~~~~~~