Language: C++


// Trouble in Shinagawa's Artifacts
//  URL: http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0198&lang=jp

#include <cstdio>
#include <cstring>
#include <vector>
#include <set>

// Ö
std::vector <int> rotate_x( std::vector <int> box );
std::vector <int> rotate_y( std::vector <int> box );
std::vector <int> rotate_z( std::vector <int> box );


// xÉñ]³¹éÖ
std::vector <int> rotate_x( std::vector <int> box )
{
	// xñ]
	// c1, c2, c3, c4, c5, c6 : default
	// c5, c1, c3, c4, c6, c2

	int tmp = box[0];
	box[0] = box[4];
	box[4] = box[5];
	box[5] = box[1];
	box[1] = tmp;

	return box;

}


// yÉñ]³¹éÖ
std::vector <int> rotate_v( std::vector <int> box )
{
	// yñ]
	// c1, c2, c3, c4, c5, c6 : default
	// c1, c4, c2, c5, c3, c6

	int tmp = box[1];
	box[1] = box[3];
	box[3] = box[4];
	box[4] = box[2];
	box[2] = tmp;

	return box;

}

// zÉñ]³¹éÖ
std::vector <int> rotate_z( std::vector <int> box )
{
	// zñ]
	// c1, c2, c3, c4, c5, c6 : default
	// c3, c2, c6, c1, c5, c4
	
	int tmp	= box[0];
	box[0]	= box[2];
	box[2]	= box[5];
	box[5]	= box[3];
	box[3]	= tmp;

	return box;

}

// Gg[|Cg
int main()
{

	// Ï
	int n;
	int answer;
	char color[32];
	std::vector <int> box( 6, 0 );
	std::set < std::vector <int> > table;

	/*
	// debug
	std::vector <int> test( 6, 0 );
	for( int i = 0; i < 6; ++i )
	{
		test[i] = i + 1;
	}

	for( int j = 0; j < 4; ++j )
	{
		if( j > 0 )
		{
			test = rotate_h( test );
		}
		printf( "¡\n" );
		for( int l = 0; l < 6; ++l )
		{
			printf( "%d: %d\n", l, test[l] );
		}
		puts( "//==================================================" );
		
		// c
		for( int k = 0; k < 4; ++k )
		{
			test = rotate_v( test );
			printf( "c\n" );
			for( int l = 0; l < 6; ++l )
			{
				printf( "%d: %d\n", l, test[l] );
			}
			puts( "//==================================================" );
		}
	}
	// debug
	*/

	while( 1 )
	{
		// ú»
		answer = 0;
		table.clear();
		for( int i = 0; i < 6; ++i )
		{
			box[i] = 0;
		}

		// üÍ
		std::fflush( stdin );
		std::scanf( "%d", &n );

		// üÍÌIíèF[ÐÆÂ
		if( n == 0 ) break;

		// nÌ¾¯ÇÝÞ
		for( int i = 0; i < n; ++i )
		{
			std::fflush( stdin );

			// FîñðüÍ
			for( int j = 0; j < 6; ++j )
			{
				std::scanf( "%s", color );

				// µ¢â·¢æ¤É¶ñ¨®ÉÏ·
				// F: Red, Yellow, Blue, Magenta, Green, Cyan
				if( std::strcmp( "Red", color ) == 0 )
					box[j] = 1;
				else if( std::strcmp( "Yellow", color ) == 0 )
					box[j] = 2;
				else if( std::strcmp( "Blue", color ) == 0 )
					box[j] = 3;
				else if( std::strcmp( "Magenta", color ) == 0 )
					box[j] = 4;
				else if( std::strcmp( "Grdeen", color ) == 0 )
					box[j] = 5;
				else if( std::strcmp( "Cyan", color ) == 0 )
					box[j] = 6;
			}

			// insertÌOÉ¯¶àÌªÈ¢©T·
			// ¯¶àÌª Á½çJEg
			if( table.find( box ) != table.end() )
			{
				++answer;
				continue;
			}

			// insertµÄ¨­
			// ¡¨cx3ð4ñ

			// x
			for( int j = 0; j < 4; ++j )
			{
				box = rotate_x( box );
				table.insert( box );
			}

			// y
			for( int j = 0; j < 4; ++j )
			{
				box = rotate_y( box );
				table.insert( box );
			}

			// z
			for( int j = 0; j < 4; ++j )
			{
				box = rotate_z( box );
				table.insert( box );
			}

		}

		// oÍ
		std::printf( "%d\n", answer );

	}

} // main()

Compiler output:
/usr/bin/ld: /tmp/ccMa4QUi.o: in function `main':
a.cc:(.text+0x644): undefined reference to `rotate_y(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status