Language: C++

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


class Dice{
public:

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'R':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'F':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'B':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'L':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	char getTop(){
		return number[0];
	}

	char getEast(){
		return number[2];
	}

	char getNorth(){
		return number[1];
	}

	char getWest(){
		return number[3];
	}

	char getBottom(){
		return number[5];
	}

	char getSouth(){
		return number[4];
	}

	void setNumber(int w0,int w1,int w2,int w3,int w4,int w5){
		number[0] = w0;
		number[1] = w1;
		number[2] = w2;
		number[3] = w3;
		number[4] = w4;
		number[5] = w5;
	}

	void setFirst(int left,int right,int front,int back,int down,int up){
		number[0] = up;
		number[1] = back;
		number[2] = right;
		number[3] = left;
		number[4] = front;
		number[5] = down;
	}

	int number[6];
	int work[6];
};

struct Info{
	int x,y,value,all_index;
};

struct Data{
	Info loc;
	int state;
};

int N;
int POW[17];
int index[15]; //サイコロが転がるマスの数
int table_index;
int dp[32768];
Info info[15][32];
char buf[31];
Data table[500]; //サイコロが転がり得るマスの集計表



void func(){

	for(int i = 0; i < N; i++)index[i] = 0;

	int current_x,current_y;
	int left,right,front,back,down,up;

	Dice dice;
	bool FLG;

	//サイコロの情報を取得
	for(int i = 0; i < N; i++){
		scanf("%d %d",&current_x,&current_y);

		scanf("%d %d %d %d %d %d",&left,&right,&front,&back,&down,&up);
		dice.setFirst(left,right,front,back,down,up);

		info[i][index[i]].x = current_x;
		info[i][index[i]].y = current_y;
		info[i][index[i]].value = dice.getBottom();

		index[i]++;

		scanf("%s",buf);

		for(int k = 0; buf[k] != '\0'; k++){

			dice.roll(buf[k]); //ダイスを転がす

			switch(buf[k]){
			case 'L':
				current_x--;
				break;
			case 'R':
				current_x++;
				break;
			case 'F':
				current_y--;
				break;
			case 'B':
				current_y++;
				break;
			}


			//既に訪れたことのあるマスか調べる
			FLG = false;

			for(int a = 0; a < index[i]; a++){
				if(info[i][a].x == current_x && info[i][a].y == current_y){
						info[i][a].value = dice.getBottom(); //新しい値で上書き
						FLG = true;
						break;
				}
			}

			if(!FLG){
				info[i][index[i]].x = current_x;
				info[i][index[i]].y = current_y;
				info[i][index[i]].value = dice.getBottom();

				index[i]++;
			}
		}
	}

	//N個のサイコロ情報を統合する
	table_index = 0;
	for(int i = 0; i < 500; i++)table[i].state = 0;

	for(int i = 0; i < N; i++){ //15
		for(int k = 0; k < index[i]; k++){ //31

			FLG = false;
			for(int a = 0; a < table_index; a++){
				if(table[a].loc.x == info[i][k].x && table[a].loc.y == info[i][k].y){ //テーブルに場所が登録済の場合
					table[a].state += POW[i]; //マス毎に、サイコロの集合を持つ
					info[i][k].all_index = a; //逆引きインデックス
					FLG = true;
					break;
				}
			}

			if(!FLG){
				table[table_index].loc.x = info[i][k].x;
				table[table_index].loc.y = info[i][k].y;
				table[table_index].state += POW[i];
				info[i][k].all_index = table_index;
				table_index++;
			}
		}
	}

	for(int state = 0; state < POW[N]; state++)dp[state] = 0;

	int sum,tmp_index,all_state;
	int next_state,next_value;

	 //★★操作を逆順にして考える★★
	for(int state = 0; state < POW[N]; state++){ //既に転がったサイコロの集合
		for(int dice = 0; dice < N; dice++){
			if(state & (1 << dice))continue;	//転がし済ならSKIP
			sum = 0;
			//あるサイコロについて、既に転がったサイコロとは重ならないマスの値の総和を求める
			for(int i = 0; i < index[dice]; i++){
				tmp_index = info[dice][i].all_index;
				all_state = table[tmp_index].state;

				if(!(all_state & state)){ //そのマスを転がる自分を含めた集合と、既に転がったサイコロの集合との論理積が0の場合:自分がそのマスを初カバー
					sum += info[dice][i].value;
				}
			}
			next_state = state+POW[dice];
			next_value = dp[state]+sum;
			dp[next_state] = max(dp[next_state],next_value);
		}
	}

	printf("%d\n",dp[POW[N]-1]);
}

int main(){

	for(int i = 0; i < 17; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Compiler output:
a.cc:88:13: error: 'int index [15]' redeclared as different kind of entity
   88 | int index[15]; //サイコロが転がるマスの数
      |             ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void func()':
a.cc:99:40: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   99 |         for(int i = 0; i < N; i++)index[i] = 0;
      |                                        ^
a.cc:114:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  114 |                 info[i][index[i]].x = current_x;
      |                              ^
a.cc:115:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  115 |                 info[i][index[i]].y = current_y;
      |                              ^
a.cc:116:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  116 |                 info[i][index[i]].value = dice.getBottom();
      |                              ^
a.cc:118:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  118 |                 index[i]++;
      |                      ^
a.cc:145:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  145 |                         for(int a = 0; a < index[i]; a++){
      |                                                 ^
a.cc:154:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  154 |                                 info[i][index[i]].x = current_x;
      |                                              ^
a.cc:155:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  155 |                                 info[i][index[i]].y = current_y;
      |                                              ^
a.cc:156:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  156 |                                 info[i][index[i]].value = dice.getBottom();
      |                                              ^
a.cc:158:38: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  158 |                                 index[i]++;
      |                                      ^
a.cc:168:41: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  168 |                 for(int k = 0; k < index[i]; k++){ //31
      |                                         ^
a.cc:201:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  201 |                         for(int i = 0; i < index[dice]; i++){
      |                                                 ^