跳到正文

题解

ABC343E题解

spacebar约 3 分钟
原文
文章信息与版本

文章信息

发布
2024年3月4日
收录
2026年5月28日
更新
2026年11月14日
篇幅
约 3 分钟
获赞
6

版本

  1. v1当前

一道暴力题。

只需枚举三个正方体顶点坐标在判断是否满足条件即可。

C++
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int s[30][30][30];
void dr(int x,int y,int z){//“画出”正方体
	for(int i=x+1,o=1;o<=7;o++,i++){
		for(int j=y+1,oo=1;oo<=7;oo++,j++){
			for(int k=z+1,ooo=1;ooo<=7;ooo++,k++){
				s[i][j][k]++;
			}
		}
	}
}
bool ch(int x1,int y1,int z1,int x2,int y2,int z2,int x3,int y3,int z3){//检查
	memset(s,0,sizeof(s));
	dr(x1,y1,z1);
	dr(x2,y2,z2);
	dr(x3,y3,z3);
	int u=0,v=0,w=0;
	for(int i=1;i<=20;i++){
		for(int j=1;j<=20;j++){
			for(int k=1;k<=20;k++){
				if(s[i][j][k]){
					if(s[i][j][k]==1){
						u++;
					}else{
						if(s[i][j][k]==2){
							v++;
						}else{
							w++;
						}
					}
				}
			}
		}
	}
	if(u==a&&v==b&&w==c){
		return 1;
	}else{
		return 0;
	}
}
int main(){
	cin>>a>>b>>c;
	if(a+2*b+c*3!=1029){
		cout<<"No";
		return 0;
	}
   //枚举坐标
   for(int x1=0;x1<=7;x1++){
		for(int y1=0;y1<=7;y1++){
			for(int z1=0;z1<=7;z1++){
	for(int x2=0;x2<=7;x2++){
		for(int y2=0;y2<=7;y2++){
			for(int z2=0;z2<=7;z2++){
	for(int x3=0;x3<=7;x3++){
		for(int y3=0;y3<=7;y3++){
				for(int z3=0;z3<=7;z3++){
							if(ch(x1,y1,z1,x2,y2,z2,x3,y3,z3)){
								cout<<"Yes\n"<<x1<<" "<<y1<<" "<<z1<<" "<<x2<<" "<<y2<<" "<<z2<<" "<<x3<<" "<<y3<<" "<<z3;
								return 0;
							}
	}}}}}}}}}
	cout<<"No";
    return 0;
}

原文
存档评论10 条抓取于