QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599024#6412. Classical Geometry ProblemmanizareWA 103ms3904kbC++142.5kb2024-09-29 00:44:462024-09-29 00:44:47

Judging History

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

  • [2024-09-29 00:44:47]
  • 评测
  • 测评结果:WA
  • 用时:103ms
  • 内存:3904kb
  • [2024-09-29 00:44:46]
  • 提交

answer

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define sz(a) (int)a.size()
#define pii pair<int,int> 
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define all(a) a.begin(),a.end() 
#define int long long 
#define ld long double

using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn =2e5 + 10 , mod = 998244353 , inf= 1e10 ;;

struct po{
	ld a[3] ; 
};

vector <pair<ld,po> > vec ;

void go(po a , ld d){
	vec.pb({d , a})	;
}

ld sq(ld f){
	ld l= 0 , r =1e9 ;
	rep(i , 1 , 200){
		ld mid = (l+r)/(ld)2; 
		if((mid*mid) <= f){
			l = mid ;
		}else{
			r = mid ;
		}
	}
	return l ;
}

ld dis(po a, po b){
	int ans =0 ;
	rep(i , 0 ,2){
		ans += abs(a.a[i]-b.a[i]) * abs(a.a[i]-b.a[i]) ;
	}
	return sq((ld)ans); 
}
int is(po f){
	bool ok =0 ;
	rep(i , 0 ,2){
		if(f.a[i] < 0 || f.a[i] > 255){
			ok = 1; 
		}
	}
	return ok ;
}
void cp(po f1){
	rep(i , 0, 2)cout << f1.a[i] << " ";
	cout << endl ;
}
po st ;
void f(po x){
	int s =0 ;
	rep(i , 0, 2){
		if(x.a[i] ==0 || x.a[i]==255){
			s++;	
		}
	}
	if(s == 3){
		go(x , dis(st  , x));
		return ;
	}
	if(s==2){
		po x2 = x  , x3 = x ;
		rep(i ,0 ,2){
			if(x.a[i]!=0 && x.a[i]!=255){
				x2.a[i]=0 ;
				x3.a[i]=255; 
			}
		}
		f(x2) ;
		go(x3 , dis(x2 , x)) ;
		return ; 
	}
	if(s==1){
		vector <int> vec ;
		rep(i , 0 , 2){
			if(x.a[i]!=0 && x.a[i]!=255){
				vec.pb(i);
			}
		}
		ld m = x.a[vec[1]]/x.a[vec[0]] ;
		po f1 = x , f2 =x , k= x ;
		k.a[vec[0]] = k.a[vec[1]] = 0 ; 
		f1.a[vec[0]] = 255 ;f2.a[vec[1]] = 255 ;
		f2.a[vec[0]] = (ld)255/m ;f1.a[vec[1]] = (ld)255*m ;
		if(is(f1) == 1)f1 = f2 ;
		f(f1) ; 
		go(k , dis(f1 , x));	
		return ; 
	}
	bool ok =0  ;
	rep(i , 0 ,2){
		po b ;
		b.a[i] = 255 ;
		rep(j , 0 ,2){
			if(j == i)continue  ;
			ld m = x.a[j]/x.a[i] ;
			b.a[j] = m*(ld)255 ;
		}
		if(is(b) == 0){
			f(b);
			go(st , dis(b , x)) ;
			break ;
		}
	} 
}
int ch(int x){
	if(x==0)return 0;
	return 255 ; 
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
	rep(i , 0 ,2)st.a[i] = 0 ; 
	int T ;
	cin >> T ;
	while(T--){
		po b;
		rep(i ,0 ,2)cin >> b.a[i] ; 
		vec.clear() ;
		f(b);
		cout<< sz(vec) << "\n" ;
		rep(i ,0 , sz(vec)-1){
			po v = vec[i].S ; ld d = vec[i].F ;
			rep(i ,0 ,2)cout << v.a[i] << " " ;
			cout  << setprecision(12) << d << "\n" ; 
		}
	}
}
/*

*/

詳細信息

Test #1:

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

input:

3
105 255 175
174 174 174
0 0 0

output:

3
0 255 255 360.624458405
255 255 255 153
0 255 0 93.2952303175
2
255 255 255 441.67295593
0 0 0 140.296115413
1
0 0 0 0

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 103ms
memory: 3848kb

input:

10000
250 128 13
1 245 2
88 183 138
179 69 194
153 246 33
255 119 192
233 30 108
26 208 33
53 162 189
225 130 10
202 137 121
152 198 25
49 165 180
228 56 30
74 18 14
6 115 31
168 242 206
90 238 139
44 103 60
16 21 190
229 209 68
41 171 181
39 74 73
181 96 18
234 95 70
75 174 84
101 16 44
202 249 80
...

output:

4
255 255 0 360.624458405
255 255 255 25.8843582111
255 0 0 125.07597691
0 0 0 5.56776436283
4
0 255 255 360.624458405
255 255 255 127.499019604
0 255 0 282.768456515
0 0 0 10
4
0 255 255 360.624458405
255 255 255 162.606887923
0 255 0 74.3572457801
0 0 0 96.5867485735
4
255 0 255 360.624458405
255 ...

result:

wrong answer too far from the target: (250.049378, 128.028675, 12.995843) instead of (250, 128, 13) (test case 1)