-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprob_00102.cpp
72 lines (70 loc) · 1.77 KB
/
prob_00102.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <bitset>
#define repf(i,b,n) for(i=b;i<n;i++)
#define repb(i,n,b) for(i=n;i>=b;i--)
#define vectIter(vect,T) for(vector<T>::iterator iter= vect.begin(), \
end= vect.end(); iter!= end; ++iter)
#define mapIter(map_,T1,T2) for(map<T1,T2>::iterator iter_= map_.begin(), \
end_= map_.end(); iter_ != end_; ++iter_)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define set_(a,i) memset(a,i,sizeof a)
#define gc getchar_unlocked
using namespace std;
int main(){
int a[3],b[3],c[3],i;
map<char,int>myMap;
myMap['B']=0; myMap['G']=1; myMap['C']=2;
while(scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&b[0],&b[1],&b[2],&c[0],&c[1],&c[2])!=-1){
string str="BCG",temp_str="BCG";
int sum=INT_MAX;
do{
int temp=0;
for(i=0;i<3;i++){
switch(i){
case 0:
switch(str[i]){
case 'B': temp+=(b[0]+c[0]); break;
case 'G': temp+=(b[1]+c[1]); break;
case 'C': temp+=(b[2]+c[2]); break;
}
break;
case 1:
switch(str[i]){
case 'B': temp+=(a[0]+c[0]); break;
case 'G': temp+=(a[1]+c[1]); break;
case 'C': temp+=(a[2]+c[2]); break;
}
break;
case 2:
switch(str[i]){
case 'B': temp+=(b[0]+a[0]); break;
case 'G': temp+=(b[1]+a[1]); break;
case 'C': temp+=(b[2]+a[2]); break;
}
break;
default: break;
}
}
if(sum>temp){
sum= temp;
temp_str= str;
}
}while(next_permutation(str.begin(),str.end()));
cout << temp_str<<" " << sum <<endl;
}
}