fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <string>
  6. #include <cmath>
  7. #include <cstdlib>
  8. #include <cstring>
  9. #include <map>
  10. #include <iterator>
  11. #include <cctype>
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. //freopen("A-large-practice.in","r",stdin);
  17. //freopen("input.txt","r",stdin);
  18. //freopen("output.txt","w",stdout);
  19. int t;
  20. cin >> t;
  21. for (int i = 1; i <= t; i++) {
  22. int n;
  23. cin >> n;
  24. vector< pair<int,int> > r;
  25. r.clear();
  26. for (int j=0;j<n;j++) {
  27. int a,b;
  28. cin >> a >> b;
  29. r.push_back(make_pair(a,b));
  30. }
  31.  
  32. int count = 0;
  33. for (int j=0;j<n-1;j++) {
  34. for (int k=j+1;k<n;k++) {
  35. if((r[j].first > r[k].first && r[j].second < r[k].second) || (r[j].first < r[k].first && r[j].second > r[k].second))
  36. count++;
  37. }
  38. }
  39.  
  40. cout << "Case #" << i << ": " << count << endl;
  41. }
  42. }
  43.  
Success #stdin #stdout 0s 3464KB
stdin
2
3
1 10
5 5
7 7
2
1 1
2 2
stdout
Case #1: 2
Case #2: 0