Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133912 王泰兮 监测点 C++ 解答错误 10 4 MS 248 KB 842 2024-03-02 10:33:46

Tests(1/10):


#include <iostream> #include <algorithm> using namespace std; struct node{ int l,r; }a[105]; bool cmp(node a,node b){ if (a.r==b.r) return a.l<b.l; return a.r<b.r; } int main(){ int t;cin >> t; while (t--){ int n; cin >> n; for (int i = 1;i<=n;i++){ int u,uu; cin >> u >> uu; a[i].l=u; a[i].r=uu; } sort(a+1,a+n+1,cmp); int Last = a[1].r; int cnt = 1; for (int i = 2;i<=n;i++){ if (a[i].r>=Last&&a[i].l<=Last){ continue; } else if (a[i-1].l>=a[i].l&&a[i].r<Last){ Last = a[i].r; } else{ cnt++; Last = a[i].r; } } cout << cnt; } }


测评信息: