这份代码
#include <iostream>
#include <map>
#define big long long
using namespace std;
struct node{
char type;
big x;
bool operator < (const struct node &a)const
{
return x > a.x;
}
};
struct node2{
big lst,anss;
};
map <node,node2> m;
big n,xx,t,sum=0,maxn=-1;
char c;
int main()
{
scanf("%lld",&n);
node last;
for(big i = 1;i <= n;i++)
{
cin >> c >> xx >> t;
if(c == 'T' || c == 'F')
{
node now = {c,xx};
if(m[now].lst == t-1)
{
m[now].lst = t;
//cout << now.type << " " << now.x << endl;
m[now].anss++;
//cout << now.type << " " << now.x << endl;
//cout << "OK ";
}
if(m[now].lst != t-1)
{
if(m[last].anss >= 3)
{
sum++, maxn = max(maxn,m[last].anss);
m[last].anss = 0;
}
m[now] = (node2){t,0};
}
//cout << m[now].anss << " " << m[now].lst << endl;
last = {c,xx};
}
}
printf("%lld %lld",sum,maxn);
return 0;
}
第 29 行的 if 运行之后,变量 anss 没有自增。
如何解决?