問題に対し、以下のようなコードを作成しました。
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
#define Vint vector<int>
#define VVint vector<Vint>
#define Fsize() front().size()
int VVint_zero(VVint vv) {
int num = 0;
for (int i = 0; i < (int)vv.size(); i++) {
for (int j = 0; j < (int)vv.Fsize(); j++) {
if (vv[i][j] == 0) num++;
}
}
return num;
}
int VVint_max(VVint vv) {
int max = INT_MIN;
for (int i = 0; i < (int)vv.size(); i++) {
for (int j = 0; j < (int)vv.Fsize(); j++) {
if (vv[i][j] > max) max = vv[i][j];
}
}
return max;
}
int main() {
int x, y, s;
string str, str_x, str_y, str_s;
VVint vec(10, Vint(10, 0));
while (getline(cin, str)) {
replace(str.begin(), str.end(), ',', ' ');
istringstream iss(str);
iss >> str_x >> str_y >> str_s;
x = stoi(str_x);
y = stoi(str_y);
s = stoi(str_s);
vec[y][x] += 1;
if (s == 1 || s == 2 || s == 3) {
if (y - 1 >= 0) vec[y - 1][x] += 1;
if (y + 1 >= 0) vec[y + 1][x] += 1;
if (x - 1 >= 0) vec[y][x - 1] += 1;
if (x + 1 >= 0) vec[y][x + 1] += 1;
}
if (s == 2 || s == 3) {
if (y - 1 >= 0 && x - 1 >= 0) vec[y - 1][x - 1] += 1;
if (y - 1 >= 0 && x + 1 >= 0) vec[y - 1][x + 1] += 1;
if (y + 1 >= 0 && x - 1 >= 0) vec[y + 1][x - 1] += 1;
if (y + 1 >= 0 && x + 1 >= 0) vec[y + 1][x + 1] += 1;
}
if (s == 3) {
if (y - 2 >= 0) vec[y - 2][x] += 1;
if (y + 2 >= 0) vec[y + 2][x] += 1;
if (x - 2 >= 0) vec[y][x - 2] += 1;
if (x + 2 >= 0) vec[y][x + 2] += 1;
}
}
cout << VVint_zero(vec) << endl;
cout << VVint_max(vec) << endl;
return 0;
}
単純に訳すると「監視対象のコマンドがある」みたいなことが書かれていますが、自分では問題箇所が分からないので指摘していただきたいです。timeout: the monitored command dumped core 0.00user 0.00system 0:00.13elapsed 0%CPU (0avgtext+0avgdata 3024maxresident)k 0inputs+8outputs (0major+231minor)pagefaults 0swaps