Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52369 AK2022071328 子网 C++ 运行出错 0 0 MS 84 KB 910 2022-07-19 12:02:19

Tests(0/20):


#include <bits/stdc++.h> using namespace std; const int maxn=10000000; deque<int>dq[maxn]; bool f[maxn]; int n,m; int ans=0; int temp=0; void dfs(int ptr,int num){ cout<<"ptr:"<<ptr<<" num:"<<num<<endl; if(ptr==m){ ans=max(ans,num); return ; } else{ for(int i=0;i<dq[ptr].size();i++){ for(int j=i+1;j<dq[ptr].size();j++){ if(!f[dq[ptr][j]] and !f[dq[ptr][j]]){ f[dq[ptr][i]]=true; f[dq[ptr][j]]=true; dfs(ptr+1,num+1); f[dq[ptr][i]]=false; f[dq[ptr][j]]=false; } dfs(ptr+1,num); } } } } void print(){ cout<<endl; for(int i=0;i<m;i++){ for(int j=0;j<dq[i].size();j++){ cout<<dq[i][j]<<" "; } cout<<endl; } cout<<endl; } int main(){ cin>>n>>m; for(int i=0;i<m;i++){ int k; cin>>k; int c; for(int j=0;j<k;j++){ cin>>c; dq[i].push_back(c); } } dfs(0,0); cout<<ans; }


测评信息: