QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#599034 | #6412. Classical Geometry Problem | manizare | AC ✓ | 104ms | 4036kb | C++14 | 2.5kb | 2024-09-29 00:47:30 | 2024-09-29 00:47:31 |
Judging History
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.0;
if((mid*mid) <= f){
l = mid ;
}else{
r = mid ;
}
}
return l ;
}
ld dis(po a, po b){
ld ans =0 ;
rep(i , 0 ,2){
ans +=(a.a[i]-b.a[i]) * (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: 0ms
memory: 3864kb
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: 0
Accepted
time: 103ms
memory: 3868kb
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.8984375 255 0 0 125.080149114 0 0 0 5.62327306824 4 0 255 255 360.624458405 255 255 255 127.5 0 255 0 282.771331073 0 0 0 10.0004164845 4 0 255 255 360.624458405 255 255 255 162.608695652 0 255 0 74.3691235346 0 0 0 96.5955726174 4 255 0 255 360.624458405 255...
result:
ok ok (10000 test cases)
Test #3:
score: 0
Accepted
time: 103ms
memory: 4036kb
input:
10000 90 173 87 39 251 59 39 43 150 106 29 130 52 55 180 236 225 70 171 15 48 92 133 240 182 226 10 126 139 105 196 7 204 32 131 193 27 96 218 67 29 33 159 9 251 130 111 243 226 69 39 198 131 80 108 169 147 45 36 170 76 138 251 55 235 186 224 165 48 51 133 173 225 14 226 234 70 139 178 92 174 138 24...
output:
4 255 255 0 360.624458405 255 255 255 246.5 0 255 0 170.157188263 0 0 0 101.214013462 4 0 255 255 360.624458405 255 255 255 168.559322034 0 255 0 233.823156893 0 0 0 4.15575853995 4 0 255 255 360.624458405 255 255 255 231.279069767 0 0 255 245.572196027 0 0 0 112.589075847 4 255 0 255 360.624458405 ...
result:
ok ok (10000 test cases)
Test #4:
score: 0
Accepted
time: 99ms
memory: 3968kb
input:
10000 186 217 161 76 0 116 246 159 161 32 245 65 206 120 71 217 76 204 109 255 245 157 59 192 55 35 87 27 147 199 190 134 31 169 64 105 5 27 255 161 2 35 244 255 232 253 106 199 28 151 129 50 24 20 172 236 234 74 51 150 179 68 178 69 42 192 152 1 23 177 169 71 216 190 125 136 223 193 255 168 49 74 2...
output:
4 255 255 0 360.624458405 255 255 255 220.725806452 0 255 0 48.1801215749 0 0 0 57.4436604843 3 0 0 255 255 255 0 255 167.068965517 0 0 0 166.176281341 4 255 0 255 360.624458405 255 255 255 251.832298137 255 0 0 123.834480236 0 0 0 12.2283814752 4 0 255 255 360.624458405 255 255 255 125.538461538 0 ...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 100ms
memory: 3880kb
input:
10000 26 6 234 114 6 172 198 19 173 214 204 1 104 186 218 199 182 82 47 240 186 223 240 143 184 99 164 184 155 37 185 4 114 49 253 17 239 214 37 0 231 38 73 245 212 121 102 155 86 234 219 157 173 216 236 46 65 103 67 130 27 253 105 83 105 197 81 93 254 47 206 225 207 110 24 38 119 248 76 243 180 10 ...
output:
4 255 0 255 360.624458405 255 255 255 58.8461538462 0 0 255 232.623886246 0 0 0 21.1360920057 4 255 0 255 360.624458405 255 255 255 13.4210526316 0 0 255 86.1073871979 0 0 0 99.6175800241 4 255 0 255 360.624458405 255 255 255 28.0057803468 255 0 0 32.3905656529 0 0 0 75.8897846374 4 255 255 0 360.62...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 104ms
memory: 3868kb
input:
10000 122 50 52 152 12 229 149 135 184 140 164 193 2 251 109 180 33 217 241 225 126 33 165 94 57 163 242 85 164 132 179 131 197 185 186 185 216 145 74 95 203 40 158 236 193 245 97 111 144 61 52 9 67 157 44 113 152 132 82 110 130 182 33 96 168 202 10 184 228 173 243 124 198 29 180 196 15 47 153 63 54...
output:
4 255 0 255 360.624458405 255 255 255 245.192307692 255 0 0 202.975532802 0 0 0 154.511269265 4 255 0 255 360.624458405 255 255 255 20.1315789474 0 0 255 86.0091456629 0 0 0 31.2359162215 4 255 0 255 360.624458405 255 255 255 231.040268456 0 0 255 65.4537478653 0 0 0 105.167686393 4 0 255 255 360.62...
result:
ok ok (10000 test cases)
Test #7:
score: 0
Accepted
time: 103ms
memory: 3868kb
input:
10000 218 94 126 189 17 30 100 251 196 67 123 128 157 60 0 161 139 95 179 210 67 98 91 45 186 227 63 242 172 226 173 1 24 66 118 98 194 75 112 189 176 43 243 226 174 112 93 67 202 143 142 117 216 97 108 179 239 161 97 91 233 111 216 110 231 208 195 20 203 43 24 22 189 205 79 98 167 102 230 139 185 1...
output:
4 255 0 255 360.624458405 255 255 255 190.238095238 255 0 0 134.262557846 0 0 0 45.616512064 4 255 0 255 360.624458405 255 255 255 144.5 255 0 0 246.57280356 0 0 0 67.0894380165 4 0 255 255 360.624458405 255 255 255 130.102040816 0 255 0 62.7288795402 0 0 0 5.31939205273 4 0 255 255 360.624458405 25...
result:
ok ok (10000 test cases)
Test #8:
score: 0
Accepted
time: 103ms
memory: 3900kb
input:
10000 58 139 199 227 23 87 52 111 207 249 83 64 55 125 147 142 246 229 118 194 7 164 16 252 59 36 140 143 180 64 167 127 108 202 51 10 172 6 150 28 149 45 72 217 154 236 88 23 4 226 232 225 109 37 172 245 69 190 112 71 81 40 143 124 38 213 124 112 178 169 61 176 180 125 234 1 63 157 51 215 59 75 216...
output:
4 0 255 255 360.624458405 255 255 255 106.402877698 0 0 255 83.3091965279 0 0 0 70.2312133075 4 255 0 255 360.624458405 255 255 255 67.4137931034 255 0 0 162.671695217 0 0 0 30.1199088891 4 0 255 255 360.624458405 255 255 255 119.459459459 0 0 255 130.594633091 0 0 0 55.7843840203 4 255 255 0 360.62...
result:
ok ok (10000 test cases)
Test #9:
score: 0
Accepted
time: 103ms
memory: 3864kb
input:
10000 154 183 17 8 28 144 3 227 218 175 43 0 209 191 38 123 96 107 56 179 204 230 197 204 188 100 217 43 189 158 161 254 191 83 240 178 150 193 187 123 122 48 157 207 135 103 84 235 62 53 66 77 2 234 237 56 156 219 127 51 184 225 70 138 102 218 53 203 153 39 98 75 171 45 134 159 215 212 128 35 190 1...
output:
4 255 255 0 360.624458405 255 255 255 28.1493506494 0 255 0 40.6553049426 0 0 0 94.3393042522 4 0 255 255 360.624458405 255 255 255 72.8571428571 0 0 255 213.63655806 0 0 0 113.246933979 4 0 255 255 360.624458405 255 255 255 3.50917431193 0 255 0 10.1110894316 0 0 0 38.8226985812 3 255 0 0 255 255 2...
result:
ok ok (10000 test cases)
Test #10:
score: 0
Accepted
time: 103ms
memory: 3924kb
input:
10000 250 227 91 46 34 201 210 87 230 102 2 191 107 0 185 104 203 241 250 164 144 40 123 155 61 164 38 200 197 253 155 124 18 219 173 90 127 124 225 217 94 50 242 198 116 227 79 191 120 136 155 184 151 174 45 122 243 248 142 31 31 154 253 152 165 224 238 39 128 165 134 229 162 220 33 61 111 11 205 1...
output:
4 255 255 0 360.624458405 255 255 255 102.224669604 255 0 0 25.2748770591 0 0 0 6.99456932198 4 255 0 255 360.624458405 255 255 255 188.47826087 0 0 255 244.525771041 0 0 0 56.1441117406 4 255 0 255 360.624458405 255 255 255 105.642857143 0 0 255 24.0014828252 0 0 0 35.1490547405 4 255 0 255 360.624...
result:
ok ok (10000 test cases)
Test #11:
score: 0
Accepted
time: 100ms
memory: 3860kb
input:
10000 208 135 142 248 171 248 162 65 32 9 162 63 91 20 90 188 236 117 62 200 71 14 228 53 68 196 133 27 159 255 129 86 121 46 216 3 213 65 177 7 28 45 215 136 153 108 54 113 254 122 99 243 222 89 18 255 48 14 157 204 210 33 132 87 4 33 231 222 233 30 14 100 10 45 226 49 210 232 113 79 18 235 109 14 ...
output:
4 255 0 255 360.624458405 255 255 255 242.429577465 255 0 0 111.644115217 0 0 0 64.5684849039 3 255 0 255 360.624458405 255 255 255 175.826612903 0 0 0 11.0134550491 4 255 255 0 360.624458405 255 255 255 125.538461538 255 0 0 170.185215882 0 0 0 101.876719187 4 0 255 255 360.624458405 255 255 255 36...
result:
ok ok (10000 test cases)
Test #12:
score: 0
Accepted
time: 103ms
memory: 3928kb
input:
10000 119 133 74 50 106 117 59 203 94 72 223 194 202 156 197 61 81 108 77 80 107 240 230 250 53 54 66 133 197 44 33 113 2 83 54 163 206 241 33 41 83 202 182 57 124 37 155 241 186 245 218 153 80 29 47 83 212 41 32 94 107 89 186 58 161 214 114 106 34 17 89 16 19 117 170 169 115 74 55 143 33 6 182 196 ...
output:
4 255 255 0 360.624458405 255 255 255 158.571428571 0 255 0 31.6087399743 0 0 0 177.220482883 4 0 255 255 360.624458405 255 255 255 120.283018868 0 0 255 26.5076531745 0 0 0 195.328917292 4 0 255 255 360.624458405 255 255 255 160.053191489 0 255 0 161.657276414 0 0 0 59.2638280509 4 0 255 255 360.62...
result:
ok ok (10000 test cases)
Test #13:
score: 0
Accepted
time: 101ms
memory: 3856kb
input:
10000 170 100 234 20 253 12 243 196 46 206 129 235 149 5 166 232 179 7 149 75 45 98 197 156 206 22 133 230 176 54 159 228 135 170 92 118 90 61 180 9 26 18 21 65 122 40 143 87 125 192 199 176 35 144 44 85 243 153 238 203 227 9 212 200 74 226 253 135 20 139 117 222 230 43 212 42 201 224 22 222 152 191...
output:
4 255 0 255 360.624458405 255 255 255 150 0 0 255 80.9152119931 0 0 0 27.464471102 4 255 255 0 360.624458405 255 255 255 153 0 255 0 273.870361132 0 0 0 2.00848082376 4 255 255 0 360.624458405 255 255 255 59.8469387755 255 0 0 50.6611110877 0 0 0 15.5834357246 4 255 0 255 360.624458405 255 255 255 1...
result:
ok ok (10000 test cases)
Test #14:
score: 0
Accepted
time: 99ms
memory: 3904kb
input:
10000 67 216 241 14 40 250 28 215 219 200 241 181 3 167 13 227 218 113 85 72 151 116 20 162 202 252 17 54 184 231 49 90 219 117 173 19 37 53 223 10 195 119 118 128 187 46 208 215 54 85 104 71 99 34 234 95 0 44 223 10 14 248 47 123 70 75 245 118 231 131 187 137 34 62 21 4 118 233 40 183 96 242 97 190...
output:
4 0 255 255 360.624458405 255 255 255 79.0972222222 0 0 255 27.6956133074 0 0 0 19.1987966141 4 0 255 255 360.624458405 255 255 255 89.25 0 0 255 226.940831275 0 0 0 5.07133118619 4 0 255 255 360.624458405 255 255 255 33.2093023256 0 0 255 4.69686527859 0 0 0 50.6584158706 4 255 255 0 360.624458405 ...
result:
ok ok (10000 test cases)
Test #15:
score: 0
Accepted
time: 101ms
memory: 3860kb
input:
10000 252 245 224 4 171 9 240 190 208 69 15 254 4 230 90 0 255 17 6 26 58 150 187 237 239 242 146 255 227 231 232 117 26 44 255 111 183 1 9 121 85 207 15 245 120 247 181 40 1 255 164 244 139 255 131 248 27 161 24 241 63 44 16 207 36 251 15 227 163 49 7 180 27 7 23 61 254 235 14 8 11 200 7 3 26 254 3...
output:
4 255 255 0 360.624458405 255 255 255 233.142857143 255 0 0 9.59763794874 0 0 0 4.96165854887 4 0 255 255 360.624458405 255 255 255 113.333333333 0 255 0 264.364077838 0 0 0 84.1392095675 4 255 0 255 360.624458405 255 255 255 232.932692308 255 0 0 46.0497584302 0 0 0 23.1304047738 4 255 0 255 360.62...
result:
ok ok (10000 test cases)
Test #16:
score: 0
Accepted
time: 96ms
memory: 3864kb
input:
10000 10 7 240 232 252 180 5 169 10 1 40 6 252 2 242 245 8 5 249 17 249 255 2 233 12 3 1 2 6 253 252 254 2 251 245 6 254 4 252 10 244 245 254 218 52 255 8 4 20 112 248 253 0 254 250 234 1 226 245 216 11 6 2 245 139 0 8 28 233 1 11 24 246 250 253 9 124 17 255 26 1 14 251 46 2 14 248 233 1 44 12 255 1...
output:
4 255 0 255 360.624458405 255 255 255 178.5 0 0 255 298.297702859 0 0 0 15.0193885112 4 255 255 0 360.624458405 255 255 255 197.844827586 0 255 0 25.6150810007 0 0 0 4.60651219998 4 0 255 255 360.624458405 255 255 255 127.5 0 255 0 268.228923514 0 0 0 86.1879882281 4 0 255 255 360.624458405 255 255 ...
result:
ok ok (10000 test cases)
Test #17:
score: 0
Accepted
time: 83ms
memory: 3808kb
input:
10000 0 3 254 9 1 2 250 254 0 4 1 65 212 3 253 253 255 254 252 1 255 255 230 11 253 215 255 113 12 16 252 253 0 255 254 254 254 255 252 0 32 254 255 36 252 10 1 243 3 46 11 99 3 255 250 0 248 11 5 3 253 254 255 23 2 1 0 253 4 255 255 248 255 237 250 7 13 1 251 251 246 0 0 4 0 2 1 254 254 0 189 3 0 2...
output:
3 0 0 255 255 0 255 255 3.01181102362 0 0 0 1.00006974771 4 255 0 255 360.624458405 255 255 255 127.5 255 0 0 221.743407769 0 0 0 253.478905544 3 0 255 0 255 255 255 0 250.984251969 0 0 0 1.40312221047 4 255 0 255 360.624458405 255 255 255 63.75 0 0 255 246.672723102 0 0 0 190.381864782 4 255 0 255 ...
result:
ok ok (10000 test cases)
Test #18:
score: 0
Accepted
time: 61ms
memory: 3876kb
input:
10000 0 253 255 255 252 2 255 0 255 250 253 255 253 0 255 252 251 236 8 255 0 247 254 254 2 255 255 255 255 252 0 0 4 6 250 0 7 32 0 0 2 255 255 9 255 3 255 1 255 255 242 254 0 0 0 0 254 0 255 255 1 0 9 255 255 2 0 255 0 0 0 255 254 9 1 253 255 254 252 0 255 0 0 255 254 0 252 255 247 0 2 250 255 255...
output:
2 0 0 255 255 0 255 255 253 3 255 255 0 360.624458405 255 255 255 2.02380952381 255 0 0 3.00009448075 1 255 0 255 360.624458405 3 0 255 255 360.624458405 255 255 255 251.976284585 0 0 255 2.81170780147 2 0 0 255 255 255 0 255 253 4 255 255 0 360.624458405 255 255 255 239.760956175 255 0 0 1.38894736...
result:
ok ok (10000 test cases)
Test #19:
score: 0
Accepted
time: 43ms
memory: 3864kb
input:
10000 0 0 0 255 0 255 0 255 255 255 255 1 0 0 0 0 255 1 255 0 254 0 255 0 0 203 255 0 2 0 255 0 255 255 254 0 255 0 255 255 255 228 0 255 255 0 255 255 0 254 0 253 0 0 242 0 0 255 0 0 255 252 0 0 0 0 0 0 0 255 255 255 0 0 255 255 255 0 4 255 0 0 1 0 0 0 255 0 253 253 0 255 255 0 0 255 255 0 0 1 255 ...
output:
1 0 0 0 0 1 255 0 255 360.624458405 1 0 255 255 360.624458405 2 255 255 0 360.624458405 255 255 255 1 1 0 0 0 0 2 0 255 0 255 0 255 255 1 2 255 0 0 255 255 0 255 254 1 0 255 0 255 2 0 0 255 255 0 255 255 203 2 0 0 0 0 0 255 0 2 1 255 0 255 360.624458405 2 255 0 0 255 255 255 0 254 1 255 0 255 360.62...
result:
ok ok (10000 test cases)
Test #20:
score: 0
Accepted
time: 30ms
memory: 3904kb
input:
10000 0 0 0 0 255 255 255 0 255 255 255 0 255 255 255 255 0 0 255 255 255 0 0 255 0 0 0 0 0 255 255 255 0 0 0 255 255 0 0 0 0 0 255 255 0 0 0 255 0 0 0 255 255 0 0 0 255 0 255 0 255 0 255 0 255 255 0 255 0 0 255 0 1 0 255 255 0 254 255 0 255 255 255 255 0 255 255 255 0 255 255 0 255 0 255 255 255 25...
output:
1 0 0 0 0 1 0 255 255 360.624458405 1 255 0 255 360.624458405 1 255 255 0 360.624458405 1 255 255 255 441.67295593 1 255 0 0 255 1 255 255 255 441.67295593 1 0 0 255 255 1 0 0 0 0 1 0 0 255 255 1 255 255 0 360.624458405 1 0 0 255 255 1 255 0 0 255 1 0 0 0 0 1 255 255 0 360.624458405 1 0 0 255 255 1 ...
result:
ok ok (10000 test cases)