QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699729#5981. Costly Binary SearchXuYueming0 0ms3920kbC++23659b2024-11-02 10:31:592024-11-02 10:32:01

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 10:32:01]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3920kb
  • [2024-11-02 10:31:59]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

// #define Hydro

const int N = 2010;

char cost[N];
int n;

int dfs(int l, int r) {
    static int f[N][N];
    if (l > r) return 0;
    if (f[l][r]) return f[l][r];
    int& res = f[l][r] = 0x3f3f3f3f;
    for (int i = l; i <= r; ++i)
        res = min(res, max(dfs(l, i - 1), dfs(i + 1, r)) + (cost[i] ^ 48));
    return res;
}

signed main() {
    #ifdef Hydro
    freopen("cost.in", "r", stdin);
    freopen("cost.out", "w", stdout);
    #endif
    scanf("%s", cost + 1);
    n = strlen(cost + 1);
    printf("%d", dfs(1, n));
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3852kb

input:

50
8
5128831164925953487661279378526736416489768154389124821528467927357884749642747626797857463132866343496157991453139582295398452863172464853698678624523849653538713928372648295734165346972222781179687541337591976277864785653638476127839556323849395641196246971351933655287441377531627938395427487...

output:

5

result:

wrong answer 1st lines differ - expected: 'Case #1: 8', found: '5'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3920kb

input:

50
647322722753778843259213887674615134214258235986992692879314555957455541351526284343217116351733247781713552149464672262787737941588358671583528664757823365936975517145283412965139791726299864122725212222496898855627124979178341548651669956711341742838725446489235961853391195148929571712449139335...

output:

5

result:

wrong answer 1st lines differ - expected: 'Case #1: 42', found: '5'