fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define n_l '\n'
  5. #define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
  6. template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)), __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); }
  7. #define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
  8.  
  9. /*expanded version*/
  10. /*
  11.  template <typename T, size_t N>
  12.  int SIZE(const T (&t)[N]){
  13.   return N;
  14.  }
  15.  
  16.  template<typename T>
  17.  int SIZE(const T &t){
  18.   return t.size();
  19.  }
  20.  
  21.  string to_string(const string s, int x1=0, int x2=1e9){
  22.   return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"';
  23.  }
  24.  
  25.  string to_string(const char* s) {
  26.   return to_string((string) s);
  27.  }
  28.  
  29.  string to_string(const bool b) {
  30.   return (b ? "true" : "false");
  31.  }
  32.  
  33.  string to_string(const char c){
  34.   return string({c});
  35.  }
  36.  
  37.  template<size_t N>
  38.  string to_string(const bitset<N> &b, int x1=0, int x2=1e9){
  39.   string t = "";
  40.   for(int __iii__ = min(x1,SIZE(b)), __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){
  41.   t += b[__iii__] + '0';
  42.   }
  43.   return '"' + t + '"';
  44.  }
  45.  
  46.  template <typename A, typename... C>
  47.  string to_string(const A (&v), int x1=0, int x2=1e9, C... coords);
  48.  
  49.  int l_v_l_v_l = 0, t_a_b_s = 0;
  50.  
  51.  template <typename A, typename B>
  52.  string to_string(const pair<A, B> &p) {
  53.   l_v_l_v_l++;
  54.   string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
  55.   l_v_l_v_l--;
  56.   return res;
  57.  }
  58.  
  59.  template <typename A, typename... C>
  60.  string to_string(const A (&v), int x1, int x2, C... coords) {
  61.  
  62.   int rnk = rank<A>::value;
  63.   string tab(t_a_b_s, ' ');
  64.  
  65.   string res = "";
  66.   bool first = true;
  67.  
  68.   if(l_v_l_v_l == 0) res += n_l;
  69.   res += tab + "[";
  70.  
  71.   x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
  72.   auto l = begin(v);
  73.   advance(l, x1);
  74.   auto r = l;
  75.   advance(r, (x2-x1) + (x2 < SIZE(v)));
  76.  
  77.   for (auto e = l; e != r; e = next(e)) {
  78.   if (!first) {
  79.   res += ", ";
  80.   }
  81.   first = false;
  82.  
  83.   l_v_l_v_l++;
  84.   if(e != l){
  85.   if(rnk > 1) {
  86.   res += n_l;
  87.   t_a_b_s = l_v_l_v_l;
  88.   };
  89.   }
  90.   else{
  91.   t_a_b_s = 0;
  92.   }
  93.  
  94.   res += to_string(*e, coords...);
  95.   l_v_l_v_l--;
  96.   }
  97.   res += "]";
  98.   if(l_v_l_v_l == 0) res += n_l;
  99.   return res;
  100.  }
  101.  
  102.  void dbgm(){;}
  103.  template<typename Heads, typename... Tails>
  104.  void dbgm(Heads H, Tails... T){
  105.   cout << to_string(H) << " | ";
  106.   dbgm(T...);
  107. }
  108. #define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl;
  109.  
  110. //*/
  111. /*end of expanded version*/
  112.  
  113. int main(){
  114. /*..tests..*/
  115.  
  116. int j[2][2][3] = {{{4,5,6},{10,11,12}}, {{1,2,3}, {7,8,9}}};
  117. dbg(j);
  118. dbg(j,0,0,0,1,0,1);
  119.  
  120.  
  121. map<vector<int>, vector<string>> a = {{{3,4},{"sauron"}}, {{1,2},{"gandalf", "the", "grey"}}, {{5},{"frodo","bilbo"}}};
  122. dbg(a);
  123. dbg(a,0,1);
  124. dbg(a,5,5);
  125.  
  126.  
  127. set<vector<string>> b[3] = {{{"abc", "def"},{"ghi"}}, {{"klm","nop"},{"qrs"}}, {{"tuv", "wxy", "zab"}}};
  128. dbg(b,1,2,0,0,0,0,1,2);
  129. dbg(b,1,2,0,0,0,0);
  130. dbg(b,1,2,0,0);
  131. dbg(b,1,2);
  132. dbg(b);
  133.  
  134.  
  135. map<int, map<int,int>> c = {{1,{{2,3}}},{4,{{5,6},{7,8}}},{9,{{10,11}}}};
  136. dbg(c,0,0);
  137. dbg(c);
  138.  
  139.  
  140. vector<bitset<10>> q = {{12},{13},{14},{15}};
  141. dbg(q);
  142. dbg(q,1,2,0,2);
  143. dbg(q,5,5,0,2);
  144.  
  145. for(int i = 0; i < 2; ++i) {
  146. dbgm(q[i]);
  147. }
  148.  
  149.  
  150. pair<int, set<int>> m = {1, {2,3,3,3,4}};
  151. dbg(m);
  152.  
  153.  
  154. deque<int> i = {9,10,11,12};
  155. dbg(i);
  156. dbg(i,2,3);
  157.  
  158.  
  159. set<pair<int, int>> x{{1,2},{3,4}};
  160. dbg(x,1,1);
  161. dbg(x);
  162.  
  163.  
  164. string s = {"codeforces"};
  165. dbg(s,20,1);
  166. dbg(s,1,4);
  167.  
  168.  
  169. int t = 5; char u = 'R';
  170. pair<pair<double, unsigned int>, pair<int, string>> v = {{234.34534, 42}, {133, "IOI"}};
  171.  
  172. dbgm(s,t,u,v);
  173.  
  174. dbgm(5.345,7,12);
  175.  
  176.  
  177. /*
  178.   vector<vector<string>> d = {{"how", "r"}, {"u"}};
  179.   dbg(d);
  180.   dbg(d,0,1,0,0,0,1);
  181.  
  182.  
  183.   vector<string> e = {"fated", "faithful", "fatal"};
  184.   dbg(e);
  185.   dbg(e,0,2,3,4);
  186.  
  187.   char f[][5] = {{'t','r','i', 'c', 'k'},{'f','r','e','e'}};
  188.   dbg(f);
  189.   dbg(f,0,10,1,3);
  190.  
  191.  
  192.   string g[2][2] = {{"file", "input"}, {"file", "output"}};
  193.   dbg(g);
  194.   dbg(g,0,1,0,1,0,1);
  195.  
  196.  
  197.   vector<long long> h = {1,2,3,4,5};
  198.   dbg(h);
  199.   dbg(h,2,3);
  200.  
  201.  
  202.   vector<int> k[2][2] = {{{1,2,3}, {4,5}},{{6,7,8}, {9,10}}};
  203.   dbg(k);
  204.   dbg(k,0,1,0,3,0,0);
  205.  
  206.  
  207.   map<int, pair<int, int>> l = {{1,{2,3}}, {4,{5,6}}, {7,{8,9}}};
  208.   dbg(l);
  209.   dbg(l,0,1);
  210.  
  211.  
  212.   vector<double> n{3.14159265359, 2.71828};
  213.   dbg(n,0);
  214.  
  215.  
  216.   vector<unsigned long long> o{2934872934792347, 834759385742};
  217.   dbg(o,0);
  218.  
  219.   bitset<8> p[][1] = {20,21,22,23,20,21,22,23};
  220.   dbg(p);
  221.   dbg(p,1,3);
  222.  
  223.  
  224.   bitset<6> r(25);
  225.   dbg(r);
  226.   dbg(r,0,4);
  227.   dbg(r,20,1);
  228.  
  229.   */
  230. }
  231.  
Success #stdin #stdout 0s 15296KB
stdin
Standard input is empty
stdout
[j]: 
[[[4, 5, 6], 
  [10, 11, 12]], 
 [[1, 2, 3], 
  [7, 8, 9]]]

[j,0,0,0,1,0,1]: 
[[[4, 5], 
  [10, 11]]]

[a]: 
[([1, 2], ["gandalf", "the", "grey"]), ([3, 4], ["sauron"]), ([5], ["frodo", "bilbo"])]

[a,0,1]: 
[([1, 2], ["gandalf", "the", "grey"]), ([3, 4], ["sauron"])]

[a,5,5]: 
[]

[b,1,2,0,0,0,0,1,2]: 
[[["lm"]], [["uv"]]]

[b,1,2,0,0,0,0]: 
[[["klm"]], [["tuv"]]]

[b,1,2,0,0]: 
[[["klm", "nop"]], [["tuv", "wxy", "zab"]]]

[b,1,2]: 
[[["klm", "nop"], ["qrs"]], [["tuv", "wxy", "zab"]]]

[b]: 
[[["abc", "def"], ["ghi"]], [["klm", "nop"], ["qrs"]], [["tuv", "wxy", "zab"]]]

[c,0,0]: 
[(1, [(2, 3)])]

[c]: 
[(1, [(2, 3)]), (4, [(5, 6), (7, 8)]), (9, [(10, 11)])]

[q]: 
["0011000000", "1011000000", "0111000000", "1111000000"]

[q,1,2,0,2]: 
["101", "011"]

[q,5,5,0,2]: 
[]

[q[i]]: "0011000000" | 
[q[i]]: "1011000000" | 
[m]: (1, [2, 3, 4])
[i]: 
[9, 10, 11, 12]

[i,2,3]: 
[11, 12]

[x,1,1]: 
[(3, 4)]

[x]: 
[(1, 2), (3, 4)]

[s,20,1]: ""
[s,1,4]: "odef"
[s,t,u,v]: "codeforces" | 5 | R | ((234.345340, 42), (133, "IOI")) | 
[5.345,7,12]: 5.345000 | 7 | 12 |