ps 其實完全可以一個main()裡面寫完 不過還是比較習慣每個步驟寫到函式裡面.. 反正能AC就好
/*
#include <iostream>
#include <vector>
using std::vector;
struct man{ //應該要大寫才對 忘記改
int y;
int x;
int dy;
int dx;
bool onGrid; //是否在場
};
vector<vector<int>> bomber;
vector<man> vman;
bool inRange(int y,int x){
return bomber.size()-1>=y && y>=0 && bomber[0].size()-1>=x && x>=0;
}
int moveMan(){
int manCount=0;
for(auto &man:vman){ //記得要&!!
if(man.onGrid==1){
manCount+=1;
bomber[man.y][man.x]=1;
man.y+=man.dy;
man.x+=man.dx;
man.onGrid=inRange(man.y,man.x);
}
}
return manCount;
}
void litBomber(){
for(auto &man:vman){
if(man.onGrid==1){
if(bomber[man.y][man.x]!=0){
man.onGrid=0;
bomber[man.y][man.x]=-1;// 0=無炸彈 1=有炸彈 -1=上面有人 準備被引爆
}
}
}
for(int i=0;i<=bomber.size()-1;i++){ // 引爆炸彈
for(int j=0;j<=bomber[0].size()-1;j++){
if(bomber[i][j]==-1){
bomber[i][j]=0;
}
}
}
}
int countBomber(){
int bomberCount=0;
for(int i=0;i<=bomber.size()-1;i++){
for(int j=0;j<=bomber[0].size()-1;j++){
if(bomber[i][j]==1){
bomberCount+=1;
}
}
}
return bomberCount;
}
void conduct(){
int runTime=0;int manCount;
while(runTime<100){runTime++;
manCount=moveMan();
if(manCount==0){break;}
litBomber();
}
}
int main(){
int n,m,k;std::cin>>n>>m>>k;
bomber=vector<vector<int>> (n,vector<int> (m,0));
int r_,c_,s_,t_;
for(int i=1;i<=k;i++){
std::cin>>r_>>c_>>s_>>t_;
vman.push_back({r_,c_,s_,t_,1});
}
conduct();
std::cout<<countBomber();
}
*/