ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1767. The House of Doctor Dee

long long is not really necessary
Posted by ASK 17 Nov 2010 21:21
unsigned is enough:

template <typename T, typename G>
void psort(T& a, T& b, T& c, T& d, G gt){
  if(gt(a, b)) swap(a, b);
  if(gt(c, d)) swap(c, d);
  if(gt(a, c)){ swap(a, c); swap(b, d); }
}
inline unsigned intersection_length(int a, int b, int c, int d){
  psort(a, b, c, d, greater<int>());
  if(c > b){ cout << 0 << endl; exit(0); }
  return min(b, d) - c;
}