Language: C++

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <iomanip>
#include <functional>
#include <complex>
#include <array>

using namespace std;
template<class T,class U>inline constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>inline constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
using pii=pair<int,int>;

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
  return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
    auto v=vmake(args...);
    return vector<decltype(v)>(n,move(v));
}

constexpr int MAX=(1<<30)-1;
int dx[]={0,1,-1,0},dy[]={1,0,0,-1};

vector<string> C;
int height,width;
map<string,int> to_number;
map<int,string> to_mozi;

int pre_cntmine=0;

//pacID,typeID,hight,width,speedleft,cooldown
vector<array<int,6>> MINE,ENEMY;
vector<array<int,6>> PRE_MINE;
vector<pii> SuperPellet,Pellet;

vector<vector<vector<vector<int>>>> Distance;


vector<vector<int>> make_distance(int sh,int sw){
    auto dist=vmake(height,width,MAX);
    queue<pii> que;
    que.emplace(sh,sw);
    dist[sh][sw]=0;
    while(!que.empty()){
        int h,w;
        tie(h,w)=que.front(); que.pop();
        for(int i=0;i<4;i++){
            int nh=h+dx[i],nw=w+dy[i];
            nh=(nh+height)%height;nw=(nw+width)%width;
            if(C[nh][nw]=='#') continue;
            if(dist[nh][nw]>dist[h][w]+1){
                dist[nh][nw]=dist[h][w]+1;
                que.emplace(nh,nw);
            }
        }
    }
    return dist;
}



//距離が2以下のところに敵がいたらそれに勝つように変化させる
//cooldownが終わってなかったら無視
//距離が近い方を優先
void type_switch(){
    for(auto v=MINE.begin();v!=MINE.end();){
        int dist=1000;
        auto mine=*v;
        int cnt=0;
        int number;
        if(mine[5]){
            v++;continue;
        }
        for(auto enemy:ENEMY){
            int tmp=abs(mine[2]-enemy[2])+abs(mine[3]-enemy[3]);
            if(chmin(dist,tmp)){
                number=cnt;
            }
            cnt++;
        }
        if(dist>2){
            v++; continue;
        }else{
            int next_hand=(ENEMY[number][1]+1)%3;
            if(mine[1]==next_hand){
                v++;continue;
            }else{
                cout<<"SWITCH "<<mine[0]<<" "<<to_mozi[next_hand]<<"|";
                v=MINE.erase(v);
            }
        }
    }
}
int find_distance(array<int,6> &x,pii &y){
    return Distance[x[2]][x[3]][y.first][y.second];
}
int find_distance(array<int,6> &x,array<int,6> &y){
    return Distance[x[2]][x[3]][y[2]][y[3]];
}

void use_Super_dfs(int idx,int value_max,int number,vector<int> &koho,vector<int> &ans,int &min_sum){
    if(idx==number){
        //同じのがあったら弾く
        for(int i=0;i<number;i++){
            for(int j=i+1;j<number;j++){
                if(koho[i]==koho[j]) return;
            }
        }
        //総和を出す
        int tmp_sum=0;
        for(int i=0;i<number;i++){
            if((int)MINE.size()<=koho[i]) continue;
            tmp_sum+=find_distance(MINE[koho[i]],SuperPellet[i]);
        }
        if(chmin(min_sum,tmp_sum)){
            ans=koho;
        }
        return;
    }
    for(int i=0;i<value_max;i++){
        koho[idx]=i;
        use_Super_dfs(idx+1,value_max,number,koho,ans,min_sum);
    }
}

void use_Super(){
    int Super_num=(int)SuperPellet.size();
    vector<int> koho(Super_num);
    vector<int> ans;
    int min_sum=1000000;
    int value_max=max(Super_num,(int)MINE.size());
    use_Super_dfs(0,value_max,Super_num,koho,ans,min_sum);
    int cnt=0;
    for(auto m=MINE.begin();m!=MINE.end();cnt++){
        auto x=*m;
        int num=-1;
        for(int i=0;i<(int)ans.size();i++){
            if(cnt==ans[i]) num=i;
        }
        if(num!=-1){
            cout<<"MOVE "<<x[0]<<" "<<SuperPellet[num].second<<" "<<SuperPellet[num].first<<"|";
            m=MINE.erase(m);
        }else{
            m++;
        }
    }
}

void use_Normal(){
    for(auto m:MINE){
        int min_dist=2000;
        pii to={-1,-1};
        for(auto p:Pellet){
            if(chmin(min_dist,find_distance(m,p))){
                to=p;
            }
        }
        if(to.first!=-1) cout<<"MOVE "<<m[0]<<" "<<to.second<<" "<<to.first<<"|";
        else{
            for(int i=0;i<4;i++){
                int nh=m[2]+dx[i],nw=m[3]+dy[i];
                nh=(nh+height)%height;
                nw=(nw+width)%width;
                if(C[nh][nw]!='#'){
                    cout<<"MOVE "<<m[0]<<" "<<nw<<" "<<nh<<"|";
                    break;
                }
            }
        }
    }
}

void Turn_init(){
    MINE.clear();
    ENEMY.clear();
    SuperPellet.clear();
    Pellet.clear();
    for(auto s=skip.begin();s!=skip.end();){
        (*s)[3]--;;
        if((*s)[3]<0){
            s=skip.erase(s);
        }else s++;
    }
}

void Game_init(){
    to_mozi[0]="ROCK";
    to_mozi[1]="PAPER";
    to_mozi[2]="SCISSORS";
    to_mozi[3]="ROCK";
    to_number["ROCK"]=0;
    to_number["PAPER"]=1;
    to_number["SCISSORS"]=2;

    cin >> width >> height; cin.ignore();
    C.resize(height);
    for (int i = 0; i < height; i++) {
        string row;
        getline(cin,row);
        C[i]=row;
    }
}

//ID,離れたいid,turn
vector<array<int,4>> skip;

void do_collision(){
    vector<bool> same(MINE.size(),false);
    for(int i=0;i<MINE.size();i++){
        for(int j=0;j<PRE_MINE.size();j++){
            if(MINE[i][0]==PRE_MINE[j][0] and find_distance(MINE[i],PRE_MINE[j])==0){
                same[i]=true;
            }
        }
    }

    for(int i=0;i<MINE.size();i++){
        for(int j=i+1;j<MINE.size();j++){
            if(!(same[i] and same[j])) continue;

            //〇〇の場合
            if(find_distance(MINE[i],MINE[j])<=2){
                skip.emplace_back(i,j,5);
                skip.emplace_back(j,i,5);
            }
        }
    }
}

void do_skip(){
    for(auto m=MINE.begin();m!=MINE.end();m++){
        for()
    }
}

void do_speed(){
    for(auto m=MINE.begin();m!=MINE.end();){
        auto x=*m;
        if(x[4]==0 and x[5]==0 and SuperPellet.size()){
            cout<<"SPEED "<<x[0]<<"|";
            m=MINE.erase(m);
        }else{
            m++;
        }
    }
}


int main()
{
    Game_init();
    Distance=vmake(height,width,height,width,0); 
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(C[i][j]=='#') continue;
            Distance[i][j]=make_distance(i,j);
        }
    }
    // game loop
    while (1) {
        Turn_init();
        int myScore;
        int opponentScore;
        cin >> myScore >> opponentScore; cin.ignore();
        int visiblePacCount; // all your pacs and enemy pacs in sight
        cin >> visiblePacCount; cin.ignore();
        cerr<<opponentScore<<endl;
        for (int i = 0; i < visiblePacCount; i++) {
            int pacId; // pac number (unique within a team)
            bool mine; // true if this pac is yours
            int x; // position in the grid
            int y; // position in the grid
            string typeId; // unused in wood leagues
            int speedTurnsLeft; // unused in wood leagues
            int abilityCooldown; // unused in wood leagues
            cin >> pacId >> mine >> x >> y >> typeId >> speedTurnsLeft >> abilityCooldown; cin.ignore();
            if(mine){
                MINE.push_back({pacId,to_number[typeId],y,x,speedTurnsLeft,abilityCooldown});
            }else{
                ENEMY.push_back({pacId,to_number[typeId],y,x,speedTurnsLeft,abilityCooldown});
            }
        }

        int visiblePelletCount; // all pellets in sight
        cin >> visiblePelletCount; cin.ignore();
        for (int i = 0; i < visiblePelletCount; i++) {
            // amount of points this pellet is worth
            int h,w,v;
            cin >> w >> h >> v; cin.ignore();
            if(v==10){
                SuperPellet.emplace_back(h,w);
            }else{
                Pellet.emplace_back(h,w);
            }
        }
        do_speed();
        type_switch();
        do_collision();
        do_skip();

        use_Super();
        use_Normal();
        cout<<endl;
        PRE_MINE=MINE;
        // Write an action using cout. DON'T FORGET THE "<< endl"
        // To debug: cerr << "Debug messages..." << endl;
    }
}

Compiler output:
a.cc: In function 'void Turn_init()':
a.cc:197:16: error: 'skip' was not declared in this scope
  197 |     for(auto s=skip.begin();s!=skip.end();){
      |                ^~~~
a.cc: In function 'void do_skip()':
a.cc:251:13: error: expected primary-expression before ')' token
  251 |         for()
      |             ^
a.cc:252:5: error: expected primary-expression before '}' token
  252 |     }
      |     ^
a.cc:251:14: error: expected ';' before '}' token
  251 |         for()
      |              ^
      |              ;
  252 |     }
      |     ~         
a.cc:252:5: error: expected primary-expression before '}' token
  252 |     }
      |     ^
a.cc:251:14: error: expected ')' before '}' token
  251 |         for()
      |            ~ ^
      |              )
  252 |     }
      |     ~         
a.cc:252:5: error: expected primary-expression before '}' token
  252 |     }
      |     ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from a.cc:4:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::array<int, 4>; _Args = {int&, int&, int}; _Tp = std::array<int, 4>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 4>; _Args = {int&, int&, int}; _Tp = std::array<int, 4>; allocator_type = std::allocator<std::array<int, 4> >]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int}; _Tp = std::array<int, 4>; _Alloc = std::allocator<std::array<int, 4> >; reference = std::array<int, 4>&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:242:34:   required from here
  242 |                 skip.emplace_back(i,j,5);
      |                 ~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'std::array<int, 4>::array(int)'
In file included from /usr/include/c++/14/functional:65,
                 from a.cc:18:
/usr/include/c++/14/array:100:12: note: candidate: 'std::array<int, 4>::array()'
  100 |     struct array
      |            ^~~~~
/usr/include/c++/14/array:100:12: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/array:100:12: note: candidate: 'constexpr std::array<int, 4>::array(const std::array<int, 4>&)'
/usr/include/c++/14/array:100:12: note:   no known conversion for argument 1 from 'int' to 'const std::array<int, 4>&'
/usr/include/c++/14/array:100:12: note: candidate: 'constexpr std::array<int, 4>::array(std::array<int, 4>&&)'
/usr/include/c++/14/array:100:12: note:   no known conversion for argument 1 from 'int' to 'std::array<int, 4>&&'