QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#652945#6412. Classical Geometry ProblemericmegalovaniaRE 0ms0kbC++202.0kb2024-10-18 19:20:372024-10-18 19:20:37

Judging History

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

  • [2024-10-18 19:20:37]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-18 19:20:37]
  • 提交

answer

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

#define ONLINE
#ifndef ONLINE
char DEBUG_BUFFER[1000];
#define debug(...) {sprintf(DEBUG_BUFFER,##__VA_ARGS__);\
cerr<<"\033[1;36m"<<DEBUG_BUFFER<<"\033[0;2m"<<"\033[0m";}
#else
#define debug(...) ;
#endif

using LL=long long;
using PII=pair<int,int>;

#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

#define FAST_IO {ios::sync_with_stdio(false);cin.tie(nullptr);}
inline int read(){static int x; cin>>x; return x;}
inline LL readLL(){static LL x; cin>>x; return x;}
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

using LD=long double;
const LD eps=1e-6;

bool sign(const LD& x){
	return !(fabs(x)<eps);
}

LD calc(const array<LD,3>& a){
	return sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
}

int cnt=0;
LD dfs(const array<LD,3>& a,stringstream& ans){
	array<int,3>vec{255,255,255};
	LD lambda=1e9;
	for(int i=0;i<3;i++){
		if(sign(a[i])){
			lambda=fmin(lambda,a[i]/255);
		}
		else vec[i]=0;
	}
	auto b=a;
	for(int i=0;i<3;i++){
		b[i]-=lambda*vec[i];
	}
	bool _=0;
	for(int i=0;i<3;i++){
		_|=sign(b[i]);
	}
	cout<<b[0]<<' '<<b[1]<<' '<<b[2]<<"\n";
	if(_) dfs(b,ans);
	++cnt;
	for(int i=0;i<3;i++){
		ans<<vec[i]<<' ';
	}
	debug("\n");
	debug("b\t{%.6Lf,%.6Lf,%.6Lf}\n",b[0],b[1],b[2]);
	debug("vec\t{%.6Lf,%.6Lf,%.6Lf}\n",vec[0]-b[0],vec[1]-b[1],vec[2]-b[2]);
	debug("l\t%.6Lf\n",lambda);
	debug("add\t{%.6Lf,%.6Lf,%.6Lf}\n",a[0]-b[0],a[1]-b[1],a[2]-b[2]);
	ans<<fixed<<setprecision(12)<<calc({a[0]-b[0],a[1]-b[1],a[2]-b[2]})<<"\n";
}
void solve(){
	stringstream ans;
	array<LD,3>a;
	cin>>a[0]>>a[1]>>a[2];
	cnt=0;
	dfs(a,ans);
	cout<<cnt<<"\n"<<ans.str();
}

int main(){
	FAST_IO;
	int T=1;
	cin>>T; //remember this !!!!!!
	while(T--) solve();
	return 0;
}

/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
105 255 175
174 174 174
0 0 0

output:


result: