QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408291#8174. Set ConstructionNetwork_ErrorWA 17ms3748kbC++141.6kb2024-05-09 23:22:572024-05-09 23:22:59

Judging History

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

  • [2024-05-09 23:22:59]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3748kb
  • [2024-05-09 23:22:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define int long long
int n,m;
map<int,bool> vis;
vector<int> st,ans;
bool chk(){
	for(int i=1;i<st.size();i++)
		for(int j=0;j<i;j++) 
			if(!vis[st[i]|st[j]]||!vis[st[i]&st[j]])return 0; return 1;
}
int N5M15[15]={0,31,8,12,16,17,18,19,24,25,26,27,28,29,30};
bool dfs(int i,int n,int m){
//	if(n==5&&m==15)return ans=vector<int>(N5M15,N5M15+15),1;
	if(st.size()>m)return 0;
	if(i>=(1ll<<n)-1){
		if(st.size()==m&&chk())return ans=st,1;return 0;
	}
	
	if(st.size()<m){
		st.pb(i),vis[i]=1;
		if(dfs(i+1,n,m))return 1;
		st.pop_back(),vis[i]=0;
	}
	
	if(dfs(i+1,n,m))return 1;return 0;
}
vector<int> sol(int n,int m){
	deb(n),deb(m)<<'\n';
	if(n<=5&&m<=15){
		vis[0]=vis[(1ll<<n)-1]=1;
		st.pb(0),st.pb((1ll<<n)-1);
			dfs(1,n,m);
//			deb(ans.size()),deb(n),deb(m)<<'\n';
					return ans;
	} 
	if(m<=n*(n-1)/2){
		auto ans=sol(n-1,m);
		for(auto &x:ans){
			x<<=1;
			if(x+2==(1ll<<n))x++;
		}			return ans;
	}
	if(~m&1){
		auto ans=sol(n-1,m/2);
		vector<int> res(0);
		for(auto &x:ans)res.pb(x<<1),res.pb(x<<1|1);
					return res;
	}
	if(m&1){
		auto ans=sol(n-1,m-1);
		for(auto &x:ans)x=x<<1|1;
		ans.pb(0);	return ans;
	}
}
void work(){
	st.clear(),vis.clear(),ans.clear();
	cin>>n>>m;
	auto ans=sol(n,m);
	for(auto x:ans)cout<<x<<' ';cout<<'\n';
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;cin>>T;while(T--)work();
}


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3748kb

input:

3
3 5
4 8
60 2

output:

0 7 1 2 3 
0 15 1 2 3 5 7 11 
0 1152921504606846975 

result:

ok AC

Test #2:

score: -100
Wrong Answer
time: 17ms
memory: 3528kb

input:

30
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 15
6 16
6 17
6 18
6 19
6 20
6 21
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
7 11

output:

0 63 
0 63 2 
0 63 2 6 
0 63 2 4 6 
0 63 2 4 6 14 
0 63 2 4 6 10 14 
0 63 2 4 6 10 14 30 
0 63 2 4 6 8 10 12 14 
0 63 2 4 6 8 10 12 14 30 
0 63 2 4 6 8 10 12 14 22 30 
0 63 2 4 6 8 10 12 14 22 30 46 
0 63 2 4 6 8 10 12 14 18 22 26 30 
0 63 2 4 6 8 10 12 14 18 22 26 30 46 
0 63 2 4 6 8 10 12 14 18 22...

result:

wrong answer (22 OR 46) is not in A