求助,玄学
  • 板块灌水区
  • 楼主XingnoYi
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/9/5 22:12
  • 上次更新2023/11/2 22:36:37
查看原帖
求助,玄学
735797
XingnoYi楼主2023/9/5 22:12

这份代码

#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;
}

第 2929 行的 if 运行之后,变量 anss 没有自增。 如何解决?

2023/9/5 22:12
加载中...