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
| #include <bits/stdc++.h> using namespace std; int num_of_out,d[3] = {0};
int transfer(string a){ if(a=="SO"||a=="FO"||a=="GO")return 0; else if(a=="1B")return 1; else if(a=="2B")return 2; else if(a=="3B")return 3; else return 4; }
int win(int c){ int s = 0; if(c!=4){ for(int i=0;i<c;i++){ if(d[2-i])s++; } for(int i=0;i<3-c;i++){ d[2-i] = d[2-c-i]; } } if(c==4){ for(int i=0;i<3;i++)if(d[i])s++; s++; } else d[c-1] = 1; for(int i=0;i<c-1;i++)d[i] = 0; return s; }
int main(){ int data[9][5]; for(int i=0;i<9;i++){ int temp; cin>>temp; for(int k=0;k<temp;k++){ string a; cin>>a; data[i][k] = transfer(a); } } cin>>num_of_out; int now_out = 0,ans = 0; for(int k=0;k<5;k++){ for(int i=0;i<9;i++){ if(now_out>=num_of_out)break; if(data[i][k]){ ans+=win(data[i][k]); } else{ now_out++; if(now_out%3==0){ for(int i =0;i<3;i++)d[i] = 0; } } } } cout<<ans<<endl; }
|