piggy123 @ 2022-03-17 09:31:50
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct node {
ll pos,type,id;
bool operator<(node b)const {
return id<b.id;
}
} nodes[2005];
ll cnter=0,vis[2005],qwq[2005];
int main() {
ll n,m;
cin >> n >> m;
for (ll i=1; i<=m; i++) {
ll f,t;
cin >> f >> t;
nodes[++cnter]= {f,1,i};
nodes[++cnter]= {t,0,i};
}
sort(nodes+1,nodes+cnter+1,[](node a,node b) {
if (a.type==0&&b.type==0)
return (a.pos==b.pos?a.id<b.id:a.pos<b.pos);
else
return (a.pos==b.pos?a.id>b.id:a.pos<b.pos);
});
priority_queue<node> pq;
for (ll i=1; i<=cnter; i++) {
if (nodes[i].type==1) {
pq.push(nodes[i]);
}
node tp= {0,0,0};
if (!pq.empty())
tp=pq.top();
while (!pq.empty()&&qwq[tp.id]) {
pq.pop();
tp=pq.top();
}
if (!qwq[tp.id]&&(abs(tp.pos-nodes[i].pos)>=1||tp.id==nodes[i].id))
vis[tp.id]=1;
// cout << tp.id << " "<< nodes[i].pos << endl;
if (nodes[i].type==0) {
qwq[nodes[i].id]=1;
}
}
ll cnt=0;
for (ll i=1; i<=m; i++)if (vis[i])cnt++;
cout << cnt;
return 0;
}
by sw2022 @ 2022-03-17 10:27:48
见过100分求hack的没见过60分求hack的
by zxy123bc @ 2022-03-17 10:45:13
@sw2022_
他是想照着hack调
by zxy123bc @ 2022-03-17 10:45:39
可能是吧
by piggy123 @ 2022-03-17 11:18:01
@sw2022_ 您可能理解错我意思了,我想照着hack调试/kk