Submission #1270138

#TimeUsernameProblemLanguageResultExecution timeMemory
1270138truongdz_top12로봇 대회 (IOI23_robot)C++20
Compilation error
0 ms0 KiB
#include "robot.h" #pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; const string dir="HWSEN"; const int nothing=-4; const int boundary=-3; const int obstacle=-2; const int blank=-1; const int path=0; const int west=1; const int south=2; const int east=3; const int north=4; int pos=0; pair<char,int>make_move(int&d){ return {dir[d],d}; } int prv(int&d){ return (d+1)%4+1; } int nxt(int d){ return d%4+1; } pair<char,int>get(vector<int>&S){ for(int i=0;i<5;++i) --S[i]; bool Start=(S[west]==boundary&&S[north]==boundary); bool End=(S[east]==boundary&&S[south]==boundary); if(S[pos]==blank){ if(Start){ if(S[south]==blank) return make_move(south); if(S[east]==blank) return make_move(east); return {'-',nothing}; } if(End) return {'H',east}; for(int nd=1;nd<5;++nd) if(S[nd]==prv(nd)) return make_move(nd); return {'-',nothing}; } if(S[pos]<=path) return {'-',nothing}; if(S[S[pos]]==prv(S[pos])){ int nd=nxt(S[pos]); while(S[nd]!=blank&&S[nd]!=prv(nd)) nd=nxt(nd); return make_move(nd); } for(int nd=1;nd<5;++nd) if(S[nd]==prv(nd)) return {dir[nd],S[pos]}; if(Start||count(S.begin(),S.end(),path)>0){ if(End) return {'T',path}; else return {dir[S[pos]],path}; } return {dir[S[pos]],blank}; } void program_pulibot(){ vector<int>S(5); for(S[0]=-2;S[0]<=5;++S[0]) for(S[1]=-2;S[1]<=5;++S[1]) for(S[2]=-2;S[2]<=5;++S[2]) for(S[3]=-2;S[3]<=5;++S[3]) for(S[4]=-2;S[4]<=5;++S[4]){ auto[A,Z]=get(S); if(Z!=-4) set_instruction(S,Z+1,A); } }

Compilation message (stderr)

robot.cpp: In function 'std::pair<char, int> get(std::vector<int>&)':
robot.cpp:33:34: error: binding reference of type 'int&' to 'const int' discards qualifiers
   33 |                 return make_move(south);
      |                                  ^~~~~
robot.cpp:16:29: note:   initializing argument 1 of 'std::pair<char, int> make_move(int&)'
   16 | pair<char,int>make_move(int&d){
      |                         ~~~~^
robot.cpp:35:34: error: binding reference of type 'int&' to 'const int' discards qualifiers
   35 |                 return make_move(east);
      |                                  ^~~~
robot.cpp:16:29: note:   initializing argument 1 of 'std::pair<char, int> make_move(int&)'
   16 | pair<char,int>make_move(int&d){
      |                         ~~~~^