###### tags: `CPE` # *2022/03/22 CPE_03* ## 題目: ![](https://i.imgur.com/aFRt4r4.png) ![](https://i.imgur.com/RzzqSVU.png) ## Version 1 ``` #include <iostream> #include <string> using namespace std; int main() { int total; cin >> total; for(int i = 0; i < total; i++) { int M, Y, C; string s; cin >> M >> Y >> C >> s; for (int j = 0; j < s.length(); j++) { if (s[j] == 'M') { M--; } if (s[j] == 'Y') { Y--; } if (s[j] == 'C') { C--; } else if (s[j] == 'R') { M--; Y--; } else if (s[j] == 'B') { M--; Y--; C--; } else if (s[j] == 'V') { M--; C--; } else if (s[j] == 'G') { Y--; C--; } } if (M >= 0 && Y >= 0 && C >= 0) { printf("YES %d %d %d\n",M,Y,C); } else{ cout << "NO\n"; } } } ``` ## Version 2 ``` #include <iostream> #include <string> using namespace std; int main() { int total; cin >> total; for(int i = 0; i < total; i++) { int M, Y, C; string s; cin >> M >> Y >> C >> s; for (int j = 0; j < s.length(); j++) { switch (s[j]) { case 'M': M--; break; case 'Y': Y--; break; case 'C': C--; break; case 'R': M--; Y--; break; case 'B': M--; Y--; C--; break; case 'V': M--; C--; break; case 'G': Y--; C--; break; } } if (M >= 0 && Y >= 0 && C >= 0) { printf("YES %d %d %d\n",M,Y,C); } else{ cout << "NO\n"; } } } ```