fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define f(k,n) for (int k=0;k<n;k++)
  4. #define pb push_back
  5. #define F first
  6. #define S second
  7. #define inf 2100000000
  8. #define mp(i,j) make_pair((i),(j))
  9. #define i64 unsigned __int64
  10. #define pii pair<i64,i64>
  11. #define sqr(a) ((a)*(a))
  12. #define eps 1e-4
  13. struct pairIsland {
  14. int index;
  15. i64 minV,maxV;
  16. };
  17. const int maxN = 2e5;
  18. i64 res[maxN+2];
  19. vector <pii> bridges;
  20. vector <pairIsland> islands;
  21. i64 n,m,x,y;
  22.  
  23. int compBridges(const void *a, const void *b) {
  24. return ( (*(pii*)a).F-(*(pii*)b).F );
  25. }
  26. int compIslands(const void *a, const void *b) {
  27. pairIsland x = *(pairIsland*)a,
  28. y = *(pairIsland*)b;
  29. if (x.minV<y.minV) return -1;
  30. else if (x.minV>y.minV) return 1;
  31. else if (x.maxV<y.maxV) return -1;
  32. else if (x.maxV>y.maxV) return 1;
  33. else return 0;
  34. }
  35. int isOk(pairIsland pi,i64 val) {
  36. if (val<=pi.maxV && val>=pi.minV) return 0;
  37. else if (val<pi.minV) return -1;
  38. else if (val>pi.maxV) return 1;
  39. }
  40. int searchInd(pairIsland pi) {
  41. int l=0,r=bridges.size()-1;
  42. while (l<=r) {
  43. i64 mid = (l+r)/2;
  44. if (mid==0) {
  45. int comp = isOk(pi,bridges[0].F);
  46. if (comp==0) return 0;
  47. else if (comp==1) break;
  48. else {
  49. l=mid+1;
  50. continue;
  51. }
  52. }
  53. i64 num1 = bridges[mid].F,
  54. num2 = bridges[mid-1].F;
  55. int comp1 = isOk(pi,num1),
  56. comp2 = isOk(pi,num2);
  57. if (comp1 == 0 && comp2 == 0) r=mid-1;
  58. else if (comp1 == 0 && comp2 == -1) return mid;
  59. else if (comp1 == 0 && comp2 == 1) r=mid-1;
  60. else if (comp1 == 1) r=mid-1;
  61. else if (comp1 == -1) l=mid+1;
  62. }
  63. return -1;
  64. }
  65. int main() {
  66. #ifndef ONLINE_JUDGE
  67. freopen("input.txt","r",stdin);
  68. freopen("output.txt","w",stdout);
  69. #endif
  70. i64 x,y,lastX,lastY;
  71. scanf("%I64d%I64d",&n,&m);
  72. f(i,n) {
  73. scanf("%I64d %I64d",&x,&y);
  74. if (i>0) islands.pb({i,x-lastY,y-lastX});
  75. lastX = x;
  76. lastY = y;
  77. }
  78. f(i,m) {
  79. scanf("%I64d",&x);
  80. bridges.pb({x,i+1});
  81.  
  82. }
  83. qsort(&bridges[0],m,sizeof(pii),compBridges);
  84. qsort(&islands[0],n-1,sizeof(pairIsland),compIslands);
  85. for (i64 i=0;i<n-1;i++) {
  86. int result = searchInd(islands[i]);
  87. if (result==-1) return !printf("No");
  88. else {
  89. res[islands[i].index]=bridges[result].S;
  90. bridges.erase(bridges.begin()+result);
  91. }
  92. }
  93. printf("Yes\n");
  94. f(i,n-1) printf("%I64d ",res[i+1]);
  95.  
  96. }
  97.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
123 4343
compilation info
prog.cpp:9:22: error: expected ';' at end of member declaration
 #define i64 unsigned __int64
                      ^
prog.cpp:15:5: note: in expansion of macro 'i64'
     i64 minV,maxV;
     ^
prog.cpp:15:9: error: 'minV' does not name a type
     i64 minV,maxV;
         ^
prog.cpp:18:5: error: expected initializer before 'res'
 i64 res[maxN+2];
     ^
prog.cpp:10:25: error: wrong number of template arguments (1, should be 2)
 #define pii pair<i64,i64>
                         ^
prog.cpp:19:9: note: in expansion of macro 'pii'
 vector <pii> bridges;
         ^
In file included from /usr/include/c++/4.9/utility:70:0,
                 from /usr/include/c++/4.9/algorithm:60,
                 from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:64,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_pair.h:96:12: error: provided for 'template<class _T1, class _T2> struct std::pair'
     struct pair
            ^
prog.cpp:19:12: error: template argument 1 is invalid
 vector <pii> bridges;
            ^
prog.cpp:19:12: error: template argument 2 is invalid
prog.cpp:19:21: error: invalid type in declaration before ';' token
 vector <pii> bridges;
                     ^
prog.cpp:21:5: error: expected initializer before 'n'
 i64 n,m,x,y;
     ^
prog.cpp: In function 'int compBridges(const void*, const void*)':
prog.cpp:10:25: error: wrong number of template arguments (1, should be 2)
 #define pii pair<i64,i64>
                         ^
prog.cpp:24:18: note: in expansion of macro 'pii'
     return  ( (*(pii*)a).F-(*(pii*)b).F );
                  ^
In file included from /usr/include/c++/4.9/utility:70:0,
                 from /usr/include/c++/4.9/algorithm:60,
                 from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:64,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_pair.h:96:12: error: provided for 'template<class _T1, class _T2> struct std::pair'
     struct pair
            ^
prog.cpp:24:22: error: expected primary-expression before ')' token
     return  ( (*(pii*)a).F-(*(pii*)b).F );
                      ^
prog.cpp:24:23: error: expected ')' before 'a'
     return  ( (*(pii*)a).F-(*(pii*)b).F );
                       ^
prog.cpp:24:42: error: expected ')' before ';' token
     return  ( (*(pii*)a).F-(*(pii*)b).F );
                                          ^
prog.cpp: In function 'int compIslands(const void*, const void*)':
prog.cpp:29:11: error: 'struct pairIsland' has no member named 'minV'
     if (x.minV<y.minV) return -1;
           ^
prog.cpp:29:18: error: 'struct pairIsland' has no member named 'minV'
     if (x.minV<y.minV) return -1;
                  ^
prog.cpp:30:16: error: 'struct pairIsland' has no member named 'minV'
     else if (x.minV>y.minV) return 1;
                ^
prog.cpp:30:23: error: 'struct pairIsland' has no member named 'minV'
     else if (x.minV>y.minV) return 1;
                       ^
prog.cpp:31:16: error: 'struct pairIsland' has no member named 'maxV'
     else if (x.maxV<y.maxV) return -1;
                ^
prog.cpp:31:23: error: 'struct pairIsland' has no member named 'maxV'
     else if (x.maxV<y.maxV) return -1;
                       ^
prog.cpp:32:16: error: 'struct pairIsland' has no member named 'maxV'
     else if (x.maxV>y.maxV) return 1;
                ^
prog.cpp:32:23: error: 'struct pairIsland' has no member named 'maxV'
     else if (x.maxV>y.maxV) return 1;
                       ^
prog.cpp: At global scope:
prog.cpp:35:28: error: expected ',' or '...' before 'val'
 int isOk(pairIsland pi,i64 val) {
                            ^
prog.cpp: In function 'int isOk(pairIsland, unsigned int)':
prog.cpp:36:9: error: 'val' was not declared in this scope
     if (val<=pi.maxV && val>=pi.minV) return 0;
         ^
prog.cpp:36:17: error: 'struct pairIsland' has no member named 'maxV'
     if (val<=pi.maxV && val>=pi.minV) return 0;
                 ^
prog.cpp:36:33: error: 'struct pairIsland' has no member named 'minV'
     if (val<=pi.maxV && val>=pi.minV) return 0;
                                 ^
prog.cpp:37:21: error: 'struct pairIsland' has no member named 'minV'
     else if (val<pi.minV) return -1;
                     ^
prog.cpp:38:21: error: 'struct pairIsland' has no member named 'maxV'
     else if (val>pi.maxV) return 1;
                     ^
prog.cpp: In function 'int searchInd(pairIsland)':
prog.cpp:41:23: error: request for member 'size' in 'bridges', which is of non-class type 'int'
     int l=0,r=bridges.size()-1;
                       ^
prog.cpp:43:13: error: expected initializer before 'mid'
         i64 mid = (l+r)/2;
             ^
prog.cpp:44:13: error: 'mid' was not declared in this scope
         if (mid==0) {
             ^
prog.cpp:45:41: error: invalid types 'int[int]' for array subscript
             int comp = isOk(pi,bridges[0].F);
                                         ^
prog.cpp:53:13: error: expected initializer before 'num1'
         i64 num1 = bridges[mid].F,
             ^
prog.cpp:55:29: error: 'num1' was not declared in this scope
         int comp1 = isOk(pi,num1),
                             ^
prog.cpp:57:27: error: 'comp2' was not declared in this scope
         if (comp1 == 0 && comp2 == 0) r=mid-1;
                           ^
prog.cpp:57:41: error: 'mid' was not declared in this scope
         if (comp1 == 0 && comp2 == 0) r=mid-1;
                                         ^
prog.cpp:58:52: error: 'mid' was not declared in this scope
         else if (comp1 == 0 && comp2 == -1) return mid;
                                                    ^
prog.cpp:59:46: error: 'mid' was not declared in this scope
         else if (comp1 == 0 && comp2 == 1) r=mid-1;
                                              ^
prog.cpp:60:32: error: 'mid' was not declared in this scope
         else if (comp1 == 1) r=mid-1;
                                ^
prog.cpp:61:33: error: 'mid' was not declared in this scope
         else if (comp1 == -1) l=mid+1;
                                 ^
prog.cpp: In function 'int main()':
prog.cpp:70:9: error: expected initializer before 'x'
     i64 x,y,lastX,lastY;
         ^
prog.cpp:71:25: error: 'n' was not declared in this scope
     scanf("%I64d%I64d",&n,&m);
                         ^
prog.cpp:71:28: error: 'm' was not declared in this scope
     scanf("%I64d%I64d",&n,&m);
                            ^
prog.cpp:73:30: error: 'x' was not declared in this scope
         scanf("%I64d %I64d",&x,&y);
                              ^
prog.cpp:73:33: error: 'y' was not declared in this scope
         scanf("%I64d %I64d",&x,&y);
                                 ^
prog.cpp:74:29: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         if (i>0) islands.pb({i,x-lastY,y-lastX});
                             ^
prog.cpp:74:34: error: 'lastY' was not declared in this scope
         if (i>0) islands.pb({i,x-lastY,y-lastX});
                                  ^
prog.cpp:74:42: error: 'lastX' was not declared in this scope
         if (i>0) islands.pb({i,x-lastY,y-lastX});
                                          ^
prog.cpp:74:48: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         if (i>0) islands.pb({i,x-lastY,y-lastX});
                                                ^
prog.cpp:74:48: error: no matching function for call to 'std::vector<pairIsland>::push_back(<brace-enclosed initializer list>)'
prog.cpp:74:48: note: candidate is:
In file included from /usr/include/c++/4.9/vector:64:0,
                 from /usr/include/c++/4.9/queue:61,
                 from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:85,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_vector.h:913:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = pairIsland; _Alloc = std::allocator<pairIsland>; std::vector<_Tp, _Alloc>::value_type = pairIsland]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.9/bits/stl_vector.h:913:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const pairIsland&}'
prog.cpp:75:9: error: 'lastX' was not declared in this scope
         lastX = x;
         ^
prog.cpp:76:9: error: 'lastY' was not declared in this scope
         lastY = y;
         ^
prog.cpp:79:24: error: 'x' was not declared in this scope
         scanf("%I64d",&x);
                        ^
prog.cpp:4:12: error: request for member 'push_back' in 'bridges', which is of non-class type 'int'
 #define pb push_back
            ^
prog.cpp:80:17: note: in expansion of macro 'pb'
         bridges.pb({x,i+1});
                 ^
prog.cpp:80:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         bridges.pb({x,i+1});
                    ^
prog.cpp:83:21: error: invalid types 'int[int]' for array subscript
     qsort(&bridges[0],m,sizeof(pii),compBridges);
                     ^
prog.cpp:10:25: error: wrong number of template arguments (1, should be 2)
 #define pii pair<i64,i64>
                         ^
prog.cpp:83:32: note: in expansion of macro 'pii'
     qsort(&bridges[0],m,sizeof(pii),compBridges);
                                ^
In file included from /usr/include/c++/4.9/utility:70:0,
                 from /usr/include/c++/4.9/algorithm:60,
                 from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:64,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_pair.h:96:12: error: provided for 'template<class _T1, class _T2> struct std::pair'
     struct pair
            ^
prog.cpp:85:14: error: expected ';' before 'i'
     for (i64 i=0;i<n-1;i++) {
              ^
prog.cpp:85:14: error: name lookup of 'i' changed for ISO 'for' scoping [-fpermissive]
prog.cpp:85:14: note: (if you use '-fpermissive' G++ will accept your code)
prog.cpp:85:23: error: expected ')' before ';' token
     for (i64 i=0;i<n-1;i++) {
                       ^
prog.cpp:85:27: error: expected ';' before ')' token
     for (i64 i=0;i<n-1;i++) {
                           ^
prog.cpp:96:1: error: expected '}' at end of input
 }
 ^
stdout
Standard output is empty