fork download
  1. mt19937 rngQ(23478123);
  2.  
  3. ll K = rngQ();
  4.  
  5. void encode(int N, int X) {
  6. vector < ll > v(250, -1);
  7. vector < ll > b1, b2;
  8. mt19937 rng(K);
  9. for(ll i = 0; i < 250; i++){
  10. if(rng()%3 == 1 && (!i || v[i - 1] == -1) ){
  11. mx--;
  12. v[i] = rng()%2;
  13. }else{
  14. if(rng()%2) b1.pb(i);
  15. else b2.pb(i);
  16. }
  17. }
  18. for(auto u : b1) v[u] = (1 << 0) & X;
  19. for(auto u : b2) v[u] = (X >> 1) & 1;
  20. for(auto u : v) send(u);
  21. return;
  22. }
  23.  
  24. std::pair<int, int> decode(int N) {
  25. vector < ll > v(250, -1);
  26. ll mx = 130;
  27. mt19937 rng2(K);
  28. vector < ll > rem, b1, b2;
  29. for(ll i = 0; i < 250; i++){
  30. if(rng2()%3 == 1 && (!i || v[i - 1] == -1) ){
  31. mx--;
  32. v[i] = rng2()%2;
  33. }else{
  34. if(rng2()%2) b1.pb(i);
  35. else b2.pb(i);
  36. }
  37. }
  38. vector < ll > g(250);
  39. for(ll i = 0; i < 250; i++) g[i] = receive();
  40. ll sure = 0, ok1 = 0, ok2 = 0, c1 = 0, c2 = 0;
  41. for(auto u : b1){
  42. if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) sure |= g[u], ok1 = 1;
  43. if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) sure |= g[u], ok1 = 1;
  44. c1 += (g[u] == 0 ? -1 : 1);
  45. }
  46. for(auto u : b2){
  47. if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) sure |= (g[u] << 1), ok2 = 1;
  48. if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) sure |= (g[u] << 1), ok2 = 1;
  49. c2 += (g[u] == 0 ? -1 : 1);
  50. }
  51. ll a1 = sure, a2 = sure;
  52. if(!ok1 && !ok2){
  53. if(max(c1, c2) == c1){
  54. if(c1 >= 0) a1 |= 1, a2 |= 1;
  55. if(c2 >= 0) a2 |= 2;
  56. }else{
  57. if(c2 >= 0) a1 |= 2, a2 |= 2;
  58. if(c1 >= 0) a1 |= 1;
  59. }
  60. }else{
  61. if(!ok1 && c1 >= 0) a1 |= 1;
  62. if(!ok2 && c2 >= 0) a1 |= 2;
  63. }
  64. a1 = min(a1, N);
  65. a1 = max(1 , a1);
  66. a2 = max(1 , a2);
  67. a2 = min(a2, N);
  68. assert(1 <= min(a1, a2) && max(a1, a2) <= N);
  69. while(a1 == a2){
  70. a1++;
  71. if(a1 == N+1) a1 = 1;
  72. }
  73. return {a1, a2};
  74. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘mt19937’ does not name a type
 mt19937 rngQ(23478123);
 ^~~~~~~
prog.cpp:3:1: error: ‘ll’ does not name a type
 ll K = rngQ();
 ^~
prog.cpp: In function ‘void encode(int, int)’:
prog.cpp:6:5: error: ‘vector’ was not declared in this scope
     vector < ll > v(250, -1);
     ^~~~~~
prog.cpp:6:14: error: ‘ll’ was not declared in this scope
     vector < ll > v(250, -1);
              ^~
prog.cpp:6:19: error: ‘v’ was not declared in this scope
     vector < ll > v(250, -1);
                   ^
prog.cpp:7:19: error: ‘b1’ was not declared in this scope
     vector < ll > b1, b2;
                   ^~
prog.cpp:7:23: error: ‘b2’ was not declared in this scope
     vector < ll > b1, b2;
                       ^~
prog.cpp:8:5: error: ‘mt19937’ was not declared in this scope
     mt19937 rng(K);
     ^~~~~~~
prog.cpp:9:11: error: expected ‘;’ before ‘i’
     for(ll i = 0; i < 250; i++){
           ^~
           ;
prog.cpp:9:19: error: ‘i’ was not declared in this scope
     for(ll i = 0; i < 250; i++){
                   ^
prog.cpp:10:12: error: ‘rng’ was not declared in this scope
         if(rng()%3 == 1 && (!i || v[i - 1] == -1) ){
            ^~~
prog.cpp:11:13: error: ‘mx’ was not declared in this scope
             mx--;
             ^~
prog.cpp:18:18: error: unable to deduce ‘auto&&’ from ‘b1’
     for(auto u : b1) v[u] = (1 << 0) & X;
                  ^~
prog.cpp:19:18: error: unable to deduce ‘auto&&’ from ‘b2’
     for(auto u : b2) v[u] = (X >> 1) & 1;
                  ^~
prog.cpp:20:18: error: unable to deduce ‘auto&&’ from ‘v’
     for(auto u : v) send(u);
                  ^
prog.cpp:20:21: error: ‘send’ was not declared in this scope
     for(auto u : v) send(u);
                     ^~~~
prog.cpp:20:21: note: suggested alternative: ‘std’
     for(auto u : v) send(u);
                     ^~~~
                     std
prog.cpp: At global scope:
prog.cpp:24:6: error: ‘pair’ in namespace ‘std’ does not name a template type
 std::pair<int, int> decode(int N) {
      ^~~~
prog.cpp:24:1: note: ‘std::pair’ is defined in header ‘<utility>’; did you forget to ‘#include <utility>’?
prog.cpp:1:1:
+#include <utility>
 mt19937 rngQ(23478123);
prog.cpp:24:1:
 std::pair<int, int> decode(int N) {
 ^~~
stdout
Standard output is empty