結果
問題 | No.5011 Better Mo's Algorithm is Needed!! (Weighted) |
ユーザー | 👑 p-adic |
提出日時 | 2022-12-17 00:20:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 6,133 bytes |
コンパイル時間 | 3,479 ms |
実行使用メモリ | 3,596 KB |
スコア | 128,843,782 |
最終ジャッジ日時 | 2022-12-17 00:20:57 |
合計ジャッジ時間 | 38,090 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
3,480 KB |
testcase_01 | AC | 20 ms
3,356 KB |
testcase_02 | AC | 19 ms
3,520 KB |
testcase_03 | AC | 20 ms
3,492 KB |
testcase_04 | AC | 18 ms
3,372 KB |
testcase_05 | AC | 18 ms
3,376 KB |
testcase_06 | AC | 19 ms
3,408 KB |
testcase_07 | AC | 18 ms
3,372 KB |
testcase_08 | AC | 19 ms
3,428 KB |
testcase_09 | AC | 19 ms
3,352 KB |
testcase_10 | AC | 18 ms
3,360 KB |
testcase_11 | AC | 18 ms
3,528 KB |
testcase_12 | AC | 19 ms
3,388 KB |
testcase_13 | AC | 18 ms
3,480 KB |
testcase_14 | AC | 19 ms
3,424 KB |
testcase_15 | AC | 19 ms
3,360 KB |
testcase_16 | AC | 19 ms
3,368 KB |
testcase_17 | AC | 20 ms
3,436 KB |
testcase_18 | AC | 19 ms
3,364 KB |
testcase_19 | AC | 19 ms
3,424 KB |
testcase_20 | AC | 19 ms
3,368 KB |
testcase_21 | AC | 19 ms
3,368 KB |
testcase_22 | AC | 19 ms
3,524 KB |
testcase_23 | AC | 19 ms
3,464 KB |
testcase_24 | AC | 19 ms
3,372 KB |
testcase_25 | AC | 19 ms
3,484 KB |
testcase_26 | AC | 18 ms
3,368 KB |
testcase_27 | AC | 19 ms
3,368 KB |
testcase_28 | AC | 19 ms
3,360 KB |
testcase_29 | AC | 19 ms
3,356 KB |
testcase_30 | AC | 18 ms
3,356 KB |
testcase_31 | AC | 18 ms
3,408 KB |
testcase_32 | AC | 19 ms
3,376 KB |
testcase_33 | AC | 18 ms
3,356 KB |
testcase_34 | AC | 18 ms
3,360 KB |
testcase_35 | AC | 19 ms
3,448 KB |
testcase_36 | AC | 18 ms
3,404 KB |
testcase_37 | AC | 19 ms
3,420 KB |
testcase_38 | AC | 19 ms
3,376 KB |
testcase_39 | AC | 18 ms
3,476 KB |
testcase_40 | AC | 19 ms
3,356 KB |
testcase_41 | AC | 18 ms
3,444 KB |
testcase_42 | AC | 18 ms
3,372 KB |
testcase_43 | AC | 20 ms
3,408 KB |
testcase_44 | AC | 19 ms
3,360 KB |
testcase_45 | AC | 19 ms
3,404 KB |
testcase_46 | AC | 19 ms
3,424 KB |
testcase_47 | AC | 19 ms
3,440 KB |
testcase_48 | AC | 19 ms
3,364 KB |
testcase_49 | AC | 19 ms
3,444 KB |
testcase_50 | AC | 18 ms
3,360 KB |
testcase_51 | AC | 18 ms
3,368 KB |
testcase_52 | AC | 19 ms
3,448 KB |
testcase_53 | AC | 18 ms
3,548 KB |
testcase_54 | AC | 18 ms
3,424 KB |
testcase_55 | AC | 19 ms
3,448 KB |
testcase_56 | AC | 19 ms
3,596 KB |
testcase_57 | AC | 19 ms
3,424 KB |
testcase_58 | AC | 18 ms
3,520 KB |
testcase_59 | AC | 19 ms
3,468 KB |
testcase_60 | AC | 19 ms
3,408 KB |
testcase_61 | AC | 18 ms
3,352 KB |
testcase_62 | AC | 18 ms
3,524 KB |
testcase_63 | AC | 19 ms
3,496 KB |
testcase_64 | AC | 19 ms
3,492 KB |
testcase_65 | AC | 19 ms
3,516 KB |
testcase_66 | AC | 18 ms
3,356 KB |
testcase_67 | AC | 19 ms
3,416 KB |
testcase_68 | AC | 19 ms
3,492 KB |
testcase_69 | AC | 19 ms
3,520 KB |
testcase_70 | AC | 19 ms
3,544 KB |
testcase_71 | AC | 19 ms
3,528 KB |
testcase_72 | AC | 19 ms
3,412 KB |
testcase_73 | AC | 19 ms
3,364 KB |
testcase_74 | AC | 18 ms
3,424 KB |
testcase_75 | AC | 19 ms
3,424 KB |
testcase_76 | AC | 18 ms
3,408 KB |
testcase_77 | AC | 18 ms
3,420 KB |
testcase_78 | AC | 19 ms
3,528 KB |
testcase_79 | AC | 18 ms
3,380 KB |
testcase_80 | AC | 18 ms
3,548 KB |
testcase_81 | AC | 19 ms
3,412 KB |
testcase_82 | AC | 19 ms
3,488 KB |
testcase_83 | AC | 19 ms
3,408 KB |
testcase_84 | AC | 19 ms
3,432 KB |
testcase_85 | AC | 19 ms
3,372 KB |
testcase_86 | AC | 19 ms
3,356 KB |
testcase_87 | AC | 18 ms
3,476 KB |
testcase_88 | AC | 19 ms
3,440 KB |
testcase_89 | AC | 18 ms
3,388 KB |
testcase_90 | AC | 18 ms
3,456 KB |
testcase_91 | AC | 18 ms
3,452 KB |
testcase_92 | AC | 19 ms
3,364 KB |
testcase_93 | AC | 19 ms
3,524 KB |
testcase_94 | AC | 19 ms
3,492 KB |
testcase_95 | AC | 19 ms
3,356 KB |
testcase_96 | AC | 19 ms
3,372 KB |
testcase_97 | AC | 18 ms
3,368 KB |
testcase_98 | AC | 18 ms
3,516 KB |
testcase_99 | AC | 19 ms
3,356 KB |
testcase_100 | AC | 19 ms
3,524 KB |
testcase_101 | AC | 18 ms
3,436 KB |
testcase_102 | AC | 19 ms
3,448 KB |
testcase_103 | AC | 19 ms
3,520 KB |
testcase_104 | AC | 18 ms
3,516 KB |
testcase_105 | AC | 19 ms
3,412 KB |
testcase_106 | AC | 19 ms
3,424 KB |
testcase_107 | AC | 18 ms
3,408 KB |
testcase_108 | AC | 19 ms
3,524 KB |
testcase_109 | AC | 19 ms
3,404 KB |
testcase_110 | AC | 18 ms
3,436 KB |
testcase_111 | AC | 19 ms
3,360 KB |
testcase_112 | AC | 19 ms
3,496 KB |
testcase_113 | AC | 18 ms
3,356 KB |
testcase_114 | AC | 19 ms
3,420 KB |
testcase_115 | AC | 18 ms
3,408 KB |
testcase_116 | AC | 19 ms
3,436 KB |
testcase_117 | AC | 18 ms
3,436 KB |
testcase_118 | AC | 19 ms
3,448 KB |
testcase_119 | AC | 18 ms
3,488 KB |
ソースコード
// #define _GLIBCXX_DEBUG #pragma GCC optimize ( "O3" ) #pragma GCC target ( "avx" ) #include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; #define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( MIN <= A && A <= MAX ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define GETLINE( A ) string A; getline( cin , A ) #define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define FOREQINV( VAR , INITIAL , FINAL ) for( TYPE_OF( INITIAL ) VAR = INITIAL ; VAR >= FINAL ; VAR -- ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define QUIT return 0 // #define COUT( ANSWER ) cout << ( ANSWER ) << "\n"; #define COUT( ANSWER ) cout << ( ANSWER ) << endl; #define RETURN( ANSWER ) COUT( ANSWER ); QUIT #define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << "\n"; QUIT #define POWER( ANSWER , ARGUMENT , EXPONENT ) \ TYPE_OF( ARGUMENT ) ANSWER{ 1 }; \ { \ TYPE_OF( ARGUMENT ) ARGUMENT_FOR_SQUARE_FOR_POWER = ( ARGUMENT ); \ TYPE_OF( EXPONENT ) EXPONENT_FOR_SQUARE_FOR_POWER = ( EXPONENT ); \ while( EXPONENT_FOR_SQUARE_FOR_POWER != 0 ){ \ if( EXPONENT_FOR_SQUARE_FOR_POWER % 2 == 1 ){ \ ANSWER *= ARGUMENT_FOR_SQUARE_FOR_POWER; \ } \ ARGUMENT_FOR_SQUARE_FOR_POWER *= ARGUMENT_FOR_SQUARE_FOR_POWER; \ EXPONENT_FOR_SQUARE_FOR_POWER /= 2; \ } \ } \ #define POWER_MOD( ANSWER , ARGUMENT , EXPONENT , MODULO ) \ TYPE_OF( ARGUMENT ) ANSWER{ 1 }; \ { \ TYPE_OF( ARGUMENT ) ARGUMENT_FOR_SQUARE_FOR_POWER = ( MODULO + ( ARGUMENT ) % MODULO ) % MODULO; \ TYPE_OF( EXPONENT ) EXPONENT_FOR_SQUARE_FOR_POWER = ( EXPONENT ); \ while( EXPONENT_FOR_SQUARE_FOR_POWER != 0 ){ \ if( EXPONENT_FOR_SQUARE_FOR_POWER % 2 == 1 ){ \ ANSWER = ( ANSWER * ARGUMENT_FOR_SQUARE_FOR_POWER ) % MODULO; \ } \ ARGUMENT_FOR_SQUARE_FOR_POWER = ( ARGUMENT_FOR_SQUARE_FOR_POWER * ARGUMENT_FOR_SQUARE_FOR_POWER ) % MODULO; \ EXPONENT_FOR_SQUARE_FOR_POWER /= 2; \ } \ } \ #define FACTORIAL_MOD( ANSWER , ANSWER_INV , MAX_I , LENGTH , MODULO ) \ ll ANSWER[LENGTH]; \ ll ANSWER_INV[LENGTH]; \ { \ ll VARIABLE_FOR_PRODUCT_FOR_FACTORIAL = 1; \ ANSWER[0] = VARIABLE_FOR_PRODUCT_FOR_FACTORIAL; \ FOREQ( i , 1 , MAX_I ){ \ ANSWER[i] = ( VARIABLE_FOR_PRODUCT_FOR_FACTORIAL *= i ) %= MODULO; \ } \ POWER_MOD( FACTORIAL_MAX_INV , ANSWER[MAX_I] , MODULO - 2 , MODULO ); \ ANSWER_INV[MAX_I] = FACTORIAL_MAX_INV; \ FOREQINV( i , MAX_I - 1 , 0 ){ \ ANSWER_INV[i] = ( FACTORIAL_MAX_INV *= i + 1 ) %= MODULO; \ } \ } \ \ // 通常の二分探索 #define BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \ ll ANSWER = MAXIMUM; \ { \ ll VARIABLE_FOR_BINARY_SEARCH_L = MINIMUM; \ ll VARIABLE_FOR_BINARY_SEARCH_U = ANSWER; \ ll VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH = ( TARGET ) - ( EXPRESSION ); \ if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH == 0 ){ \ VARIABLE_FOR_BINARY_SEARCH_L = ANSWER; \ } else { \ ANSWER = ( VARIABLE_FOR_BINARY_SEARCH_L + VARIABLE_FOR_BINARY_SEARCH_U ) / 2; \ } \ while( VARIABLE_FOR_BINARY_SEARCH_L != ANSWER ){ \ VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH = ( TARGET ) - ( EXPRESSION ); \ if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH == 0 ){ \ VARIABLE_FOR_BINARY_SEARCH_L = ANSWER; \ break; \ } else { \ if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH > 0 ){ \ VARIABLE_FOR_BINARY_SEARCH_L = ANSWER; \ } else { \ VARIABLE_FOR_BINARY_SEARCH_U = ANSWER; \ } \ ANSWER = ( VARIABLE_FOR_BINARY_SEARCH_L + VARIABLE_FOR_BINARY_SEARCH_U ) / 2; \ } \ } \ } \ \ // 二進法の二分探索 #define BS2( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \ ll ANSWER = MINIMUM; \ { \ ll VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 = 1; \ ll VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH = ( MAXIMUM ) - ANSWER; \ while( VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 <= VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH ){ \ VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 *= 2; \ } \ VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 /= 2; \ ll VARIABLE_FOR_ANSWER_FOR_BINARY_SEARCH_2 = ANSWER; \ while( VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 != 0 ){ \ ANSWER = VARIABLE_FOR_ANSWER_FOR_BINARY_SEARCH_2 + VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2; \ VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH = ( TARGET ) - ( EXPRESSION ); \ if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH == 0 ){ \ VARIABLE_FOR_ANSWER_FOR_BINARY_SEARCH_2 = ANSWER; \ break; \ } else if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH > 0 ){ \ VARIABLE_FOR_ANSWER_FOR_BINARY_SEARCH_2 = ANSWER; \ } \ VARIABLE_FOR_POWER_FOR_BINARY_SEARCH_2 /= 2; \ } \ ANSWER = VARIABLE_FOR_ANSWER_FOR_BINARY_SEARCH_2; \ } \ \ template <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : - a; } template <typename T> inline T Residue( const T& a , const T& p ){ return a >= 0 ? a % p : p - ( - a - 1 ) % p - 1; } int main() { FOR( i , 1 , 200000 ){ cout << i << " "; } RETURN( 200000 ); }