提交时间:2024-08-01 17:14:34
运行 ID: 160064
# include <bits/stdc++.h> using namespace std ; struct qj { int b , e ; void read ( ) { cin >> b >> e ; if ( b > e ) { swap ( b , e ) ; } } } a [40005] ; bool cmp ( qj a , qj b ) { return a . e != b . e ? a . e < b . e : a . b < b . b ; } int main ( ) { int n ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { a [i] . read ( ) ; } sort ( a + 1 , a + n + 1 , cmp ) ; int ans = 0 , cur = a [1] . e ; for ( int i = 2 ; i <= n ; i ++ ) { if ( a [i] . b < cur ) { ans ++ ; } else { cur = a [i] . e ; } } cout << ans << endl ; return 0 ; }