QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216018#7562. Except OnesolemnteeWA 1ms4092kbC++171.2kb2023-10-15 15:12:242023-10-15 15:12:24

Judging History

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

  • [2023-10-15 15:12:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4092kb
  • [2023-10-15 15:12:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int>a(n+2);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    //for(int i=1;i<=n;i++)a[i]+=500;
    vector<vector<vector<int>>>dp(n+1,vector<vector<int>>(n+1,vector<int>(n+2,-1)));
    a[n+1]=1e9+50;
    function<int(int,int,int)>dfs=[&](int l,int r,int val){
        if(dp[l][r][val]!=-1)return dp[l][r][val];
        if(l==r){
            if(a[l]==a[val])return dp[l][r][val]=0;
            return dp[l][r][val]=1;
        }
        dp[l][r][val]=r-l+1;
        for(int i=l;i<r;i++){
            for(int j=0;j<=n+1;j++){
                for(int k=0;k<=n+1;k++){
                    dp[l][r][val]=min(dp[l][r][val],dfs(l,i,j)+dfs(i+1,r,k)+(a[j]!=a[val])+(a[k]!=a[val]));
                }
            }
            for(int j=0;j<=n+1;j++){
                dp[l][r][val]=min(dp[l][r][val],dfs(l,i,j)+dfs(i+1,r,j)+(a[j]!=a[val]));
            }
        }
        return dp[l][r][val];
    };
    printf("%d",dfs(1,n,0));
}
/*
6
1 1 4 5 1 4

5
1 2 3 2 1

23
11 11 26 26 26 26 26 26 26 45 45 15 15 15 15 0 96 41 41 41 96 96 0
*/




Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4092kb

input:

7 5 3

output:

2

result:

wrong answer 1st numbers differ - expected: '1', found: '2'