public class SurveillanceSystem {
public string getContainerInfo(string containers, int[] reports, int L) {
int n = containers.Length;
var ans = Enumerable.Repeat('-', n).ToArray();
var cand = Enumerable.Range(0, n - L + 1)
.Select(i =>
new {
from = i,
to = i + L,
containerNum = containers.Skip(i).Take(L).Count(c => c == 'X')
}
).ToArray();
for (int i = 0; i < n; i++) {
if (cand.Where(c => c.from <= i && i < c.to && reports.Contains(c.containerNum)).Any()) {
ans[i] = '?';
}
for (int j = 0; j <= L; j++) {
int outOfRangeCandNum = cand.Count(c => c.containerNum == j && !(c.from <= i && i < c.to));
if (outOfRangeCandNum < reports.Count(r => r == j))
ans[i] = '+';
}
}
return new string(ans);
}
}