1. C++, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.540
* Category: Brute Force
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/

#include <iostream>
#include <climits>

using namespace std;

int bin[3][3];
int saveMin;

string map[3] = { "B", "G", "C" };

int main()
{
while(true)
{
for(int i=0; i < 3; i++)
for(int j=0; j < 3; j++)
cin >> bin[i][j];

if(feof(stdin))
return 0;

saveMin = INT_MAX;
int current = 0;
string result,tmpResult;

for(int i=0; i < 3; i++)
for(int j=0; j < 3; j++)
if(j != i)
for(int k=0; k < 3; k++)
if(k != i && k != j)
{
current = bin[1][i] + bin[2][i];
current += bin[0][j] + bin[2][j];
current += bin[0][k] + bin[1][k];

if(current <= saveMin)
{
if(current == saveMin)
{
string tmpResult = map[i] + map[j] + map[k];
if(tmpResult < result)
result = tmpResult;
}
else
result = map[i] + map[j] + map[k];

saveMin = current;
}
}

cout << result << " " << saveMin << endl;
}
}