WA 0 pts:
ans+=cnt[3-len];
这样写是错的,因为 len=0len=0len=0 时因统计所有 mod 3=0\bmod 3=0mod3=0 的数量,而不是 mod 3=3\bmod 3=3mod3=3。
正确写法应该是这样:
ans+=cnt[(3-len)%3];