QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#857412 | #8864. Ball Passing | gs22059test# | AC ✓ | 0ms | 4096kb | C++23 | 2.5kb | 2025-01-15 17:29:16 | 2025-01-15 17:29:17 |
Judging History
answer
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3") // optimization
//#pragma GCC optimize("Ofast") // optimization
//#pragma GCC optimize("unroll-loops") // optimization
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define i32 signed
#define int long long // CP
#define i64 long long
#define endl '\n'
#define elif else if
#define fi first
#define se second
#define pb push_back
#define p32 pair<i32,i32>
#define p64 pair<i64,i64>
#define f2(i,x) for((i)=0;(i)<(x);(i)++)
#define f2b(i,x) for((i)=(x)-1;(i)>=0;(i)--)
#define f3(i,f,t) for((i)=(f);(i)<(t);(i)++)
#define fall(x) (x).begin(), (x).end()
#define sort1(x) sort(fall(x))
#define rev(x) reverse(fall(x))
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fl fflush(stdout)
#define nl cout<<endl;fflush(stdout)
i64 gcd(i64 a, i64 b){if(a<b){a=a^b;b=a^b;a=a^b;} return b==0?a:gcd(b,a%b);}
i64 lcm(i64 a, i64 b){return a/gcd(a,b)*b;}
i64 expm(i64 a, i64 b, i64 m){i64 r=1;while(b){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r%m;}
i64 expm(i64 a, i64 b){i64 r=1,m=1e9+7;while(b){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r%m;}
i64 minv(i64 a, i64 m){return expm(a,m-2,m);}
i64 ncrm(i64 n, i64 r, i64 m){i64 i,j,k; i64 out=1; f3(i,1,n+1){out*=i;out%=m;}f3(i,1,r+1){out*=minv(i,m);out%=m;}f3(i,1,n-r+1){out*=minv(i,m);out%=m;}return out%m;}
// int n,m,k,a[300010],b[300010],c[300010];
double dist(p64 a,p64 b){
return sqrt((double)(a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}
void probA(){
int i,j,l;
}void probB(){
int i,j,l,n;
cin>>n; string s; cin>>s;
vector<p64>a,b;
for(i=0;i<n;i++){
int x,y; cin>>x>>y;
if(s[i]=='G') a.pb({x,y});
else b.pb({x,y});
} int as=a.size(),bs=b.size();
double ans=0;
for(i=0;i<as/2;i++) ans+=dist(a[i],a[i+as/2]);
for(i=0;i<bs/2;i++) ans+=dist(b[i],b[i+bs/2]);
cout<<fixed<<setprecision(10)<<ans<<endl;
}void probC(){
int i,j,l;
}void probD(){
int i,j,l;
}void probF(){
int i,j,l;
}void probG(){
int i,j,l;
}void probH(){
int i,j,l;
}void probI(){
int i,j,l;
}void probJ(){
int i,j,l;
}void probK(){
int i,j,l;
}void probL(){
int i,j,l;
}
i32 main(){
fast;
// int tc; cin>>tc;
// while(tc--)f();
probB();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3968kb
input:
4 BBGG -1 -10 -10 -2 -8 7 7 -8
output:
33.2547980144
result:
ok found '33.2547980', expected '33.2547980', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
10 GBGBBBGBBG -30 2 -28 10 -5 30 6 29 15 26 22 20 29 9 27 -12 -14 -27 -22 -20
output:
269.6953830451
result:
ok found '269.6953830', expected '269.6953830', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
18 GBBBBGBGBGBBGGGGBB -1820 -414 -1992 -92 -77 999 75 999 422 978 471 972 871 900 1343 741 1790 -446 556 -961 148 -997 28 -1000 23 -1000 -493 -969 -816 -913 -1002 -865 -1432 -698 -1671 -550
output:
21614.2813915657
result:
ok found '21614.2813916', expected '21614.2813916', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4096kb
input:
40 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 9506 -2484 9872 -1278 9980 -501 9992 -323 7528 5266 7447 5339 7074 5655 5984 6410 5834 6498 5537 6662 5459 6703 3250 7566 2640 7716 896 7968 637 7984 -1592 7898 -1863 7860 -2419 7762 -3277 7558 -3941 7353 -7798 5008 -9393 2745 -9617 2192 -9752 1772 -9882 -...
output:
351971.7532597757
result:
ok found '351971.7532598', expected '351971.7532598', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
50 BBBGBGGGGGBGGGGGGGGBBGGGGBBBBBBGGGBGGBGBGGBBGBGBGG 1420 -4949 4182 -4542 4684 -4418 5875 -4046 6094 -3964 7896 -3068 8588 -2561 8764 -2408 8929 -2251 9377 -1737 9724 -1166 8443 2679 8109 2926 7842 3103 4660 4424 4561 4450 3837 4617 3542 4676 3281 4723 3208 4736 3008 4768 1136 4968 131 5000 -1002 ...
output:
331254.0241450059
result:
ok found '331254.0241450', expected '331254.0241450', error '0.0000000'