fork(1) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <iomanip>
  14. #define dibs reserve
  15. #define OVER9000 1234567890
  16. #define patkan 9
  17. #define tisic 47
  18. #define soclose 1e-9
  19. #define pi 3.1415926535898
  20. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  21. #define chocolate win
  22. #define ff first
  23. #define ss second
  24. #define abs(x) ((x < 0)?-(x):(x))
  25. #define uint unsigned int
  26. #include <time.h>
  27. // mylittlepony
  28. using namespace std;
  29.  
  30. struct edge {
  31. int u,v,r;
  32.  
  33. bool operator<(const edge &E) const {
  34. return r < E.r;}
  35. };
  36.  
  37. int main() {
  38. cin.sync_with_stdio(0);
  39. int N;
  40. cin >> N;
  41. vector<edge> E(N);
  42.  
  43. map<int,int> P;
  44. for(int i =0; i < N; i++) {
  45. int r,x;
  46. cin >> x >> r;
  47. P[x-r] =0, P[x+r] =0;
  48. E[i].u =x-r;
  49. E[i].v =x+r;
  50. E[i].r =r;}
  51.  
  52. sort(E.begin(),E.end());
  53. int V =0;
  54. ALL_THE(P,it) {it->ss =V; V++;}
  55.  
  56. vector< vector<int> > C(V);
  57. vector<int> isC(V);
  58. int ans =N;
  59. for(int i =0; i < V; i++) {
  60. C[i].push_back(i);
  61. isC[i] =i;}
  62.  
  63. for(int i =0; i < N; i++) {
  64. int x =isC[P[E[i].u]], y =isC[P[E[i].v]];
  65. if(x == y) {
  66. ans++;
  67. continue;}
  68. if(C[x].size() > C[y].size()) swap(x,y);
  69. for(int j =0; j < C[x].size(); j++) {
  70. isC[C[x][j]] =y;
  71. C[y].push_back(C[x][j]);}
  72. }
  73. cout << ans+1 << "\n";
  74. return 0;}
  75.  
  76. // look at my code
  77. // my code is amazing
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:31: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
                               ^
prog.cpp:54:5: note: in expansion of macro ‘ALL_THE’
     ALL_THE(P,it) {it->ss =V; V++;}
     ^
prog.cpp:54:15: error: ‘it’ does not name a type
     ALL_THE(P,it) {it->ss =V; V++;}
               ^
prog.cpp:20:36: note: in definition of macro ‘ALL_THE’
 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
                                    ^
prog.cpp:54:15: error: expected ‘;’ before ‘it’
     ALL_THE(P,it) {it->ss =V; V++;}
               ^
prog.cpp:20:55: note: in definition of macro ‘ALL_THE’
 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
                                                       ^
prog.cpp:54:15: error: ‘it’ was not declared in this scope
     ALL_THE(P,it) {it->ss =V; V++;}
               ^
prog.cpp:20:55: note: in definition of macro ‘ALL_THE’
 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
                                                       ^
prog.cpp:69:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j =0; j < C[x].size(); j++) {
                                     ^
stdout
Standard output is empty