我找不到錯哪拉~~~
幫我看一下謝謝!
# include <bits/stdc++.h>
using namespace std;
int main()
{
vector<vector<string>> BaseBall;
string S;
for (int i=0; i<9; i++){
vector<string> row={};
getline(cin,S);
for (int i=2; i<S.size(); i+=3){
string Plus;
Plus.assign(S,i,2);
row.push_back(Plus);
}
BaseBall.push_back(row);
}
// =====================================
int Out, b=0, ans=0;
cin >> Out;
vector<int> Base(3,0) // 表示每個跑壘者在的壘包 0為本壘, Count={13};
for (int i=0; i<5; i++){
for (int j=0; j<9; j++){
string Game = BaseBall[j][i];
switch(Game[1]){
case 'R':
ans += 4 - count(Base.begin(),Base.end(),0);
Base[0]=0; Base[1]=0; Base[2]=0;
break;
case 'O':
b += 1;
break;
default:
int Check=0;
for (int i=0; i<3; i++){
Check += (Base[i]==0);
if (Check >= 2 && Base[i] == 0)
continue;
Base[i] += (Game[0]-48);
}
}
for (int i=0; i<3; i++){
if (Base[i] >= 4){
ans += 1;
Base[i] = 0;
}
}
Count.push_back(b);
if (b != 0 && b % 3 == 0 && Count[i*9+j] != b){
Base[0]=0; Base[1]=0; Base[2]=0;
}
/* for (int i=0; i<3; i++) cout << Base[i] << " ";
cout << b << " " << ans << " per" << '\n'; */
if (b >= Out)
break;
}
if (b >= Out)
break;
}
cout << ans << '\n';
return 0;
}
vector Base(3,0) // 表示每個跑壘者在的壘包 0為本壘, Count={13};
最多可能有4個跑壘者