Language: C++



#include <map>
#include <string>
using namespace std;
// 1<-here
//2345
// 6
//

//	{1,2,3,4,5,6}
map<string,int[6]> table={
	{"North",{3,2,6,4,1,5}},//north
	{"East",{2,6,3,1,5,4}},//east
	{"West",{4,1,3,6,5,2}},//west
	{"South",{5,2,1,4,6,3}},//south
	{"Right",{1,5,2,3,4,6}},//right
	{"Left",{1,3,4,5,2,6}} //left
};

// 1
//4235
// 6
int init[6]={1,4,2,3,5,6};

int view[6]={1,4,2,3,5,6};
int copy[6]={1,4,2,3,5,6};

void init(){
	for(int i=0;i<6;i++){
		view[i]=init[i];
	}
}

void rotate(string id){
	for(int i=0;i<6;i++){
		copy[i]=view[table[id][i]];
	}
	for(int i=0;i<6;i++){
		view[i]=copy[i];
	}
}

int main(){

	bool flag=false;
	string name="";
	int ans=0;
	do{
		ans=0;
		init();
		flag=false;
		cin >> max;
		for(int i=0;i<max;i++){
			flag=true;
			cin>>name;
			rotate(name);
			ans+=view[0];
		}
		if (flag){cout << ans;}
	}while(flag);
	return 0;
}

Compiler output:
a.cc:19:1: error: could not convert '{{"North", {3, 2, 6, 4, 1, 5}}, {"East", {2, 6, 3, 1, 5, 4}}, {"West", {4, 1, 3, 6, 5, 2}}, {"South", {5, 2, 1, 4, 6, 3}}, {"Right", {1, 5, 2, 3, 4, 6}}, {"Left", {1, 3, 4, 5, 2, 6}}}' from '<brace-enclosed initializer list>' to 'std::map<std::__cxx11::basic_string<char>, int [6]>'
   19 | };
      | ^
      | |
      | <brace-enclosed initializer list>
a.cc:29:11: error: 'void init()' redeclared as different kind of entity
   29 | void init(){
      |           ^
a.cc:24:5: note: previous declaration 'int init [6]'
   24 | int init[6]={1,4,2,3,5,6};
      |     ^~~~
a.cc: In function 'void rotate(std::string)':
a.cc:37:17: error: reference to 'copy' is ambiguous
   37 |                 copy[i]=view[table[id][i]];
      |                 ^~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/map:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:642:5: note: candidates are: 'template<class _II, class _OI> _OI std::copy(_II, _II, _OI)'
  642 |     copy(_II __first, _II __last, _OI __result)
      |     ^~~~
a.cc:27:5: note:                 'int copy [6]'
   27 | int copy[6]={1,4,2,3,5,6};
      |     ^~~~
a.cc:40:25: error: reference to 'copy' is ambiguous
   40 |                 view[i]=copy[i];
      |                         ^~~~
/usr/include/c++/14/bits/stl_algobase.h:642:5: note: candidates are: 'template<class _II, class _OI> _OI std::copy(_II, _II, _OI)'
  642 |     copy(_II __first, _II __last, _OI __result)
      |     ^~~~
a.cc:27:5: note:                 'int copy [6]'
   27 | int copy[6]={1,4,2,3,5,6};
      |     ^~~~
a.cc: In function 'int main()':
a.cc:51:21: error: 'init' cannot be used as a function
   51 |                 init();
      |                 ~~~~^~
a.cc:53:17: error: 'cin' was not declared in this scope
   53 |                 cin >> max;
      |                 ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <string>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:54:30: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<'
   54 |                 for(int i=0;i<max;i++){
      |                             ~^~~~
a.cc:60:27: error: 'cout' was not declared in this scope
   60 |                 if (flag){cout << ans;}
      |                           ^~~~
a.cc:60:27: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'