hui


私信TA

用户名:huih

访问量:4302

签 名:

等  级
排  名 236
经  验 5993
参赛次数 2
文章发表 14
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

#include<bits/stdc++.h>
using namespace std;
int n,k,res;
int ans[11],a[11];
set<int> st;
void dfs(int x,int cnt) {
    if(x>n) {
        return ;
    }
    st.clear();
    for(int i=1; i<cnt; ++i) {
        st.insert(a[i]);
    }
    if(st.size()==cnt-1) {
//        for(int i=1;i<cnt;++i){
//            cout<<ans[i]<<' ';
//        }
//        cout<<'\n';
        res=max(res,cnt-1);
    }
    ans[cnt]=a[x];
    dfs(x+1,cnt+1);
    dfs(x+1,cnt);
}
signed main() {
    cin>>n>>k;
    for(int i=1; i<=n; ++i) {
        scanf("%d",&a[i]);
    }
    dfs(1,1);
    cout<<res<<'\n';
    return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

可以取蓝桥官网试试 我的只能通过一个一个用例 在这竟然能AC 现在怀疑我之前搁这AC的代码了 哭死(;´༎ຶД༎ຶ`) 
2020-11-09 11:07:34
  • «
  • 1
  • »