Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define sc(x) scanf( "%d" , &x )
- #define REP(i , n) for( int i = 0 ; i < (n) ; ++i )
- #define clr( t , val ) memset( t , val , sizeof( t ) )
- #define pb push_back
- #define all(v) v.begin() , v.end()
- #define SZ(v) ((int)(v).size())
- #define mp make_pair
- #define fi first
- #define se second
- #define DEBUG( x ) cerr << #x << " " << x << endl;
- #define N 5000
- typedef long long ll;
- typedef vector< int > vi;
- typedef vector< vi > vvi;
- int main(){
- int n , K;
- while( sc( n ) == 1 ){
- sc( K );
- ll T = (ll)n * (ll)(n + 1);
- T /= 2;
- if( T % K ){
- puts( "NO" );
- continue;
- }
- T /= K;
- set< int > SET;
- REP( i , n ) SET.insert( i + 1 );
- vvi vec;
- while( 1 ){
- if( !SZ( SET ) ) break;
- ll cur = T;
- vi ans;
- while( 1 ){
- if( !cur ) break;
- auto it = SET.upper_bound( cur );
- if( it == SET.begin() ){
- puts( "NO" );
- return 0 ;
- }
- it --;
- ans.pb( *it );
- cur -= *it;
- SET.erase( it );
- }
- vec.pb( ans );
- }
- for( auto ans : vec ) {
- printf( "%d\n" , SZ(ans) );
- REP( i , SZ(ans) ) printf( "%d%c" , ans[ i ] , (i + 1 == SZ(ans)) ? 10 : 32 );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment