fork download
  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define all(v) v.begin() , v.end()
  5. #define sz(v) int(v.size())
  6. #define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
  7. using namespace std;
  8.  
  9. typedef long long ll;
  10. typedef pair<int , int> ii;
  11. typedef pair<long long , int> lli;
  12.  
  13. const int maxN = int(2e5)+7;
  14.  
  15. void solve(){
  16. int n , m , k;
  17. cin >> n >> m >> k;
  18. ll ans = (n + m);
  19. for (int i = 1 ; i <= k ; i++){
  20. int x , y , u , v;
  21. cin >> x >> y >> u >> v;
  22. ans += 1ll * (abs(x - u) + abs(y - v));
  23. }
  24. cout << ans - 2ll * (k + 1) << "\n";
  25. }
  26.  
  27. #define name "F"
  28.  
  29. int main(){
  30. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  31. if (fopen(name".INP" , "r")){
  32. freopen(name".INP" , "r" , stdin);
  33. freopen(name".OUT" , "w" , stdout);
  34. }
  35. int t = 1; //cin >> t;
  36. while (t--) solve();
  37. return 0;
  38. }
  39.  
  40.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
21913