Submission #438224

#TimeUsernameProblemLanguageResultExecution timeMemory
438224ApiramDungeons Game (IOI21_dungeons)C++17
Compilation error
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; queue<int>q; q.push(nnn); long long cnt=0; while(!q.empty()) { int sz = q.size(); while(sz--) { int node = q.front(); q.pop(); vis[node]=true; winning_path[node]=cnt; for(auto z : adj[node]) { if(!vis[z]) { q.push(z); } } } cnt++; } } long long simulate(int x, int zz) { vector<pair<bool,long long>>v(nnn+1,{false,0}); vector<long long>steps(nnn+1,0),seq; long long curr=0, len=0; long long z=zz; while(true) { if(v[x].first) { seq.push_back(x); long long ans = (sss[x]-z)/(curr-v[x].second); z+=ans*(curr-v[x].second);           int left=0, right=len-1, use=x; assert(len<=nnn); assert(seq.size()<=nnn); 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; } } z+=v[seq[use]].second - v[x].second; x=seq[use+1]; } 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]; steps[x]=len; x=lll[x]; len++; seq.push_back(x); }

Compilation message (stderr)

dungeons.cpp:53:2: error: extended character   is not valid in an identifier
   53 |             int left=0, right=len-1, use=x;
      |  ^
dungeons.cpp:53:5: error: extended character   is not valid in an identifier
   53 |             int left=0, right=len-1, use=x;
      |    ^
dungeons.cpp:53:8: error: extended character   is not valid in an identifier
   53 |             int left=0, right=len-1, use=x;
      |      ^
dungeons.cpp:53:11: error: extended character   is not valid in an identifier
   53 |             int left=0, right=len-1, use=x;
      |        ^
dungeons.cpp:53:14: error: extended character   is not valid in an identifier
   53 |             int left=0, right=len-1, use=x;
      |          ^
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:53:2: error: '\U000000a0' was not declared in this scope
   53 |             int left=0, right=len-1, use=x;
      |  ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dungeons.cpp:2:
dungeons.cpp:55:30: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |             assert(seq.size()<=nnn);
      |                    ~~~~~~~~~~^~~~~
dungeons.cpp:57:32: error: invalid operands of types 'std::ios_base&(std::ios_base&)' and 'std::ios_base&(std::ios_base&)' to binary 'operator+'
   57 |                 int mid = (left+right)/2;
      |                            ~~~~^~~~~~
      |                            |    |
      |                            |    std::ios_base&(std::ios_base&)
      |                            std::ios_base&(std::ios_base&)
dungeons.cpp:59:21: error: 'use' was not declared in this scope
   59 |                     use=mid;
      |                     ^~~
dungeons.cpp:60:26: error: assignment of function 'std::ios_base& std::right(std::ios_base&)'
   60 |                     right=mid-1;
      |                     ~~~~~^~~~~~
dungeons.cpp:62:25: error: assignment of function 'std::ios_base& std::left(std::ios_base&)'
   62 |                     left=mid+1;
      |                     ~~~~^~~~~~
dungeons.cpp:65:22: error: 'use' was not declared in this scope
   65 |             z+=v[seq[use]].second - v[x].second;
      |                      ^~~
dungeons.cpp:79:5: error: expected '}' at end of input
   79 |     }
      |     ^
dungeons.cpp:43:35: note: to match this '{'
   43 | long long simulate(int x, int zz) {
      |                                   ^