답안 #975016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975016 2024-05-04T10:01:31 Z LucaIlie 비스킷 담기 (IOI20_biscuits) C++17
0 / 100
1000 ms 548 KB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

const int k = 60;
long long x;
long long biscuits[k];
long long sum[k][k], mask[k][k];
vector<int> ind[k];
long long solutions;
vector<int> sol;

void countSolutions( int b, long long s ) {
    solutions++;

    //for ( int i: sol )
       // printf( "%d ", i );
    //printf( "\n" );

    for ( int i: ind[b] ) {
        long long cs = ((s / 2 + mask[b][i]) >> (i - b)) + sum[b][i];
      //  printf( "%d %d %d\n", b, i, cs );
        if ( cs >= x ) {
            sol.push_back( i );
            countSolutions( i + 1, cs - x );
            sol.pop_back();
        } else
          break;
    }
}

int p;
bool cmp( int p1, int p2 ) {
    long long r1 = sum[p][p1] - x, r2 = sum[p][p2] - x;
    return (r1 >> p2) > (r2 >> p1);
}

long long count_tastiness( long long X, vector <long long> a ) {
    long long s;

    x = X;
    a.resize( k );

    s = 0;
    for ( int b = 0; b < k; b++ ) {
        a[b] += s;
        if ( a[b] > x ) {
            s = a[b] - x;
            a[b] = x + s % 2;
            s /= 2;
        } else
            s = 0;
        biscuits[b] = a[b];
    }

    for ( int i = 0; i < k; i++ ) {
        sum[i][i] = biscuits[i];
        for ( int j = i + 1; j < k; j++ ) {
            mask[i][j] = mask[i][j - 1] + (((long long)sum[i][j - 1] % 2) << (j - i - 1));
            sum[i][j] = sum[i][j - 1] / 2 + biscuits[j];
            //printf( "%d %d: %d %d\n", i, j, sum[i][j], mask[i][j] );
        }
    }
    for ( int b = 0; b < k; b++ ) {
        ind[b].clear();
        for ( int i = b; i < k; i++ )
            ind[b].push_back( i );
        p = b;
        sort( ind[b].begin(), ind[b].end(), cmp );
    }

    solutions = 0;
    countSolutions( 0, 0 );

    return solutions;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 763 ms 548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -