1 条题解
-
0
#include <iostream> #include <string> #include <cmath> using namespace std; const int MAXN = 10000; int w11[MAXN], l11[MAXN]; int w21[MAXN], l21[MAXN]; int main() { string s; int cnt11 = 0, cnt21 = 0; int nowW11 = 0, nowL11 = 0; int nowW21 = 0, nowL21 = 0; bool stop = false; while (cin >> s && !stop) { for (char ch : s) { if (ch == 'E') { stop = true; break; } if (ch == 'W') { nowW11++; nowW21++; } else if (ch == 'L') { nowL11++; nowL21++; } if ((nowW11 >= 11 || nowL11 >= 11) && abs(nowW11 - nowL11) >= 2) { w11[cnt11] = nowW11; l11[cnt11] = nowL11; cnt11++; nowW11 = 0; nowL11 = 0; } if ((nowW21 >= 21 || nowL21 >= 21) && abs(nowW21 - nowL21) >= 2) { w21[cnt21] = nowW21; l21[cnt21] = nowL21; cnt21++; nowW21 = 0; nowL21 = 0; } } } w11[cnt11] = nowW11; l11[cnt11] = nowL11; cnt11++; w21[cnt21] = nowW21; l21[cnt21] = nowL21; cnt21++; for (int i = 0; i < cnt11; i++) { cout << w11[i] << ":" << l11[i] << endl; } cout << endl; for (int i = 0; i < cnt21; i++) { cout << w21[i] << ":" << l21[i] << endl; } return 0; }
- 1
信息
- ID
- 5164
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- 递交数
- 17
- 已通过
- 5
- 上传者