@@ -267,8 +267,8 @@ auto stepped_iota(ll start, ll end, ll step=1) {
267
267
// just as an example of how to iterate in reverse order
268
268
// for(auto& x : dat | views::reverse) {}
269
269
270
- #define GET_MACRO (_1,_2,_3,_4,NAME,...) NAME
271
- #define FOR (...) GET_MACRO (__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
270
+ #define GET_MACRO_5 (_1,_2,_3,_4,_5 ,NAME,...) NAME
271
+ #define FOR (...) GET_MACRO_5 (__VA_ARGS__, , FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
272
272
273
273
#pragma region // rangeint
274
274
V<int > rangeint (int start, int end, int inc=1 ) {
@@ -388,47 +388,6 @@ inline namespace Helpers {
388
388
void decrement (auto & ...args) {(increment_one (args, -1 ), ...);} // subtract one from each, for input. MODIFICATION IS THE GOAL
389
389
}
390
390
391
- inline namespace Input {
392
- tcT> constexpr bool needs_input_v = !is_readable_v<T> && is_iterable_v<T>;
393
-
394
- // re: read
395
- void re (auto &...args);
396
- tcTU> void re (pair<T,U>& p) { re (p.first ,p.second ); } // pairs
397
- tcT> void re (complex<T>& c) { T a,b; re (a,b); c = {a,b}; } // complex
398
- tcT> typename enable_if<needs_input_v<T>,void >::type re (T& i); // ex. vectors, arrays
399
-
400
- template <class ... Ts> void re (tuple<Ts...> &t) {
401
- apply ([](Ts &...args ) { re (args...); }, t);
402
- }
403
-
404
- tcT> typename enable_if<needs_input_v<T>,void >::type re (T& i) {
405
- each (x,i) re (x); }
406
- void re (auto & ...args) { ((cin >> args), ...); } // read multiple
407
-
408
- // rv: resize and read vectors
409
- void rv (size_t ) {}
410
- tcTUU> void rv (size_t N, V<T>& t, U&... u);
411
- template <class ...U> void rv (size_t , size_t N2, U&... u);
412
- tcTUU> void rv (size_t N, V<T>& t, U&... u) {
413
- t.resize (N); re (t);
414
- rv (N,u...); }
415
- template <class ...U> void rv (size_t , size_t N2, U&... u) {
416
- rv (N2,u...); }
417
- void rv1 (size_t ) {}
418
- tcTUU> void rv1 (size_t N, V<T>& t, U&... u) {
419
- t.resize (N); re (t); for (auto & x : t) decrement (x);
420
- rv1 (N,u...); }
421
-
422
-
423
- // dumb shortcuts to read in ints
424
- #define ints (...) int __VA_ARGS__; re(__VA_ARGS__);
425
- #define int1 (...) ints(__VA_ARGS__); decrement(__VA_ARGS__);
426
- #define chars (...) char __VA_ARGS__; re(__VA_ARGS__);
427
- #define lls (...) ll __VA_ARGS__; re(__VA_ARGS__);
428
- #define ll1 (...) lls(__VA_ARGS__); decrement(__VA_ARGS__);
429
- #define strings (...) string __VA_ARGS__; re(__VA_ARGS__);
430
- }
431
-
432
391
inline namespace ToString {
433
392
tcT> constexpr bool needs_output_v = !is_printable_v<T> && is_iterable_v<T>;
434
393
@@ -545,8 +504,8 @@ inline namespace FileIO {
545
504
}
546
505
547
506
#pragma region // debugging
548
- // * debug setup mostly stolen from tourist. https://codeforces.com/contest/1540/submission/120602670
549
- // * dcclyde added line numbers, colors, probably some other stuff.
507
+ // * debug setup adapted from from tourist. https://codeforces.com/contest/1540/submission/120602670
508
+ // * dcclyde added line numbers, colors, and some other stuff.
550
509
551
510
// for dbg printouts of C arrays.
552
511
template <typename T>
@@ -777,15 +736,19 @@ void debug_out(Head H, Tail... T) {
777
736
#define OUT_RESET " \033 [0m"
778
737
#define OUT_BOLD " \033 [;1m"
779
738
#define OUT_RED " \033 [31" " m"
780
- #define OUT_CYAN " \033 [36" BOLD_MAYBE " m"
781
- #define OUT_DEFAULT OUT_CYAN
782
- // #define OUT_GREEN "\033[32" << BOLD_MAYBE << "m"
783
739
#define OUT_GREEN " \033 [32" " m"
740
+ // #define OUT_GREEN "\033[32" << BOLD_MAYBE << "m"
741
+ #define OUT_YELLOW " \033 [33" BOLD_MAYBE " m"
784
742
#define OUT_BLUE " \033 [34" BOLD_MAYBE " m"
743
+ #define OUT_PURPLE " \033 [35" BOLD_MAYBE " m"
744
+ #define OUT_CYAN " \033 [36" BOLD_MAYBE " m"
745
+ #define OUT_BRIGHTBLUE " \033 [38;5;39m"
785
746
#define OUT_WHITE " \033 [97" " m"
786
747
#define OUT_MARK " \033 [0;30;41;1m"
787
- #define OUT_YELLOW " \033 [33" BOLD_MAYBE " m"
788
- #define OUT_PURPLE " \033 [35" BOLD_MAYBE " m"
748
+ #define OUT_LTBLUE " \033 [96m"
749
+
750
+ #define OUT_DEFAULT OUT_CYAN
751
+ #define OUT_INPUTCOLOR OUT_WHITE
789
752
790
753
791
754
#define dbgc (...) ;
@@ -803,6 +766,8 @@ void debug_out(Head H, Tail... T) {
803
766
#define dbgcB (...) ;
804
767
#define dbgW (...) ;
805
768
#define dbgcW (...) ;
769
+ #define dbgInput (...) ;
770
+ #define dbgcInput (...) ;
806
771
#define dbgGeneral (...) ;
807
772
#define dbgcGeneral (...) ;
808
773
#define dbg_only (...) ;
@@ -855,6 +820,11 @@ void debug_out(Head H, Tail... T) {
855
820
#undef dbgcW
856
821
#define dbgcW (MSG, ...) dbgcbase(OUT_GREEN, OUT_WHITE, MSG, #__VA_ARGS__, __VA_ARGS__)
857
822
823
+ #undef dbgInput
824
+ #define dbgInput (...) dbgcbase(OUT_GREEN, OUT_INPUTCOLOR, " " , #__VA_ARGS__, __VA_ARGS__)
825
+ #undef dbgcInput
826
+ #define dbgcInput (MSG, ...) dbgcbase(OUT_GREEN, OUT_INPUTCOLOR, MSG, #__VA_ARGS__, __VA_ARGS__)
827
+
858
828
#undef dbgGeneral
859
829
#define dbgGeneral (COLOR, ...) dbgcbase(OUT_GREEN, COLOR, " " , #__VA_ARGS__, __VA_ARGS__)
860
830
#undef dbgcGeneral
@@ -871,7 +841,68 @@ void debug_out(Head H, Tail... T) {
871
841
#endif
872
842
#pragma endregion
873
843
874
- #define timebomb (a ) dbg_only({static int _bomb = 0 ; if (++_bomb>=a) {dbgcBold (" boom!" , a);exit (1 );}});
844
+ inline namespace Input {
845
+ tcT> constexpr bool needs_input_v = !is_readable_v<T> && is_iterable_v<T>;
846
+
847
+ // re: read
848
+ void re (auto &...args);
849
+ tcTU> void re (pair<T,U>& p) { re (p.first ,p.second ); } // pairs
850
+ tcT> void re (complex<T>& c) { T a,b; re (a,b); c = {a,b}; } // complex
851
+ tcT> typename enable_if<needs_input_v<T>,void >::type re (T& i); // ex. vectors, arrays
852
+
853
+ template <class ... Ts> void re (tuple<Ts...> &t) {
854
+ apply ([](Ts &...args ) { re (args...); }, t);
855
+ }
856
+
857
+ tcT> typename enable_if<needs_input_v<T>,void >::type re (T& i) {
858
+ each (x,i) re (x); }
859
+ void re (auto & ...args) { ((cin >> args), ...); } // read multiple
860
+
861
+ // rv: resize and read vectors
862
+ void rv (size_t ) {}
863
+ tcTUU> void rv (size_t N, V<T>& t, U&... u);
864
+ template <class ...U> void rv (size_t , size_t N2, U&... u);
865
+ tcTUU> void rv (size_t N, V<T>& t, U&... u) {
866
+ t.resize (N); re (t);
867
+ rv (N,u...); }
868
+ template <class ...U> void rv (size_t , size_t N2, U&... u) {
869
+ rv (N2,u...); }
870
+ void rv1 (size_t ) {}
871
+ tcTUU> void rv1 (size_t N, V<T>& t, U&... u) {
872
+ t.resize (N); re (t); for (auto & x : t) decrement (x);
873
+ rv1 (N,u...); }
874
+
875
+
876
+ // dumb shortcuts to read in ints
877
+ #define readBase (TYPE, ...) TYPE __VA_ARGS__; re(__VA_ARGS__); dbgInput(__VA_ARGS__);
878
+ #define readBase1 (TYPE, ...) TYPE __VA_ARGS__; re(__VA_ARGS__); decrement(__VA_ARGS__); dbgInput(__VA_ARGS__);
879
+ #define ints (...) readBase(int , __VA_ARGS__);
880
+ #define int1 (...) readBase1(int , __VA_ARGS__);
881
+ #define chars (...) readBase(char , __VA_ARGS__);
882
+ #define char1 (...) readBase1(char , __VA_ARGS__);
883
+ #define lls (...) readBase(ll, __VA_ARGS__);
884
+ #define ll1 (...) readBase1(ll, __VA_ARGS__);
885
+ #define strings (...) readBase(string, __VA_ARGS__);
886
+
887
+ #define vecs_1 (TYPE, SIZE, A ) V<TYPE> A; rv(SIZE, A); dbgInput(SIZE, A);
888
+ #define vecs_2 (TYPE, SIZE, A, B ) vecs_1(TYPE, SIZE, A); vecs_1(TYPE, SIZE, B);
889
+ #define vecs_3 (TYPE, SIZE, A, B, C ) vecs_1(TYPE, SIZE, A); vecs_2(TYPE, SIZE, B, C);
890
+ #define vecs_4 (TYPE, SIZE, A, B, C, D ) vecs_1(TYPE, SIZE, A); vecs_3(TYPE, SIZE, B, C, D);
891
+ #define vecs_5 (TYPE, SIZE, A, B, C, D, E ) vecs_1(TYPE, SIZE, A); vecs_4(TYPE, SIZE, B, C, D, E);
892
+ #define vec1_1 (TYPE, SIZE, A ) V<TYPE> A; rv1(SIZE, A); dbgInput(SIZE, A);
893
+ #define vec1_2 (TYPE, SIZE, A, B ) vec1_1(TYPE, SIZE, A); vec1_1(TYPE, SIZE, B);
894
+ #define vec1_3 (TYPE, SIZE, A, B, C ) vec1_1(TYPE, SIZE, A); vec1_2(TYPE, SIZE, B, C);
895
+ #define vec1_4 (TYPE, SIZE, A, B, C, D ) vec1_1(TYPE, SIZE, A); vec1_3(TYPE, SIZE, B, C, D);
896
+ #define vec1_5 (TYPE, SIZE, A, B, C, D, E ) vec1_1(TYPE, SIZE, A); vec1_4(TYPE, SIZE, B, C, D, E);
897
+
898
+ #define vecs (TYPE, SIZE, ...) GET_MACRO_5(__VA_ARGS__, vecs_5, vecs_4, vecs_3, vecs_2, vecs_1)(TYPE, SIZE, __VA_ARGS__);
899
+ #define vec1 (TYPE, SIZE, ...) GET_MACRO_5(__VA_ARGS__, vec1_5, vec1_4, vec1_3, vec1_2, vec1_1)(TYPE, SIZE, __VA_ARGS__);
900
+
901
+ // #define vecs(TYPE, SIZE, ...) V<TYPE> __VA_ARGS__; rv(SIZE, __VA_ARGS__); dbgInput(__VA_ARGS__);
902
+ // #define vec1(TYPE, SIZE, ...) V<TYPE> __VA_ARGS__; rv1(SIZE, __VA_ARGS__); dbgInput(__VA_ARGS__);
903
+ }
904
+
905
+ #define timebomb (a ) dbg_only({static int _bomb=a;if (_bomb<=0 ) {dbgcBold (" boom!" , a);assert (false );exit (1 );} dbgcR (" timebomb" , _bomb); --_bomb;});
875
906
876
907
#define YES ps (" YES" );
877
908
#define NO ps (" NO" );
@@ -900,9 +931,7 @@ const int INF_i = 2'000'000'001; // 2e9 + 1
900
931
901
932
void solve () {
902
933
lls (N);
903
- V<ll> dat;
904
- rv (N, dat);
905
- dbgR (N, dat);
934
+ vecs (ll, N, A);
906
935
el;
907
936
908
937
// ! Read the sample cases AND EXPLANATIONS before writing code for nontrivial problems!
0 commit comments