#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
using namespace std;
long long n,gx,gy,lx,ly,tgx,tgy,lo,up,mid,pgx,pgy;
string pu,k;
double mi,ma,tr;
char e;
long long naj(long long mik){
pgy=gy+mik*tgy;
pgx=gx+mik*tgx;
mi=INT_MAX;
for(int i = 0; i<pu.size(); i++){
e=pu[i];
if(e=='L'){
pgx-=1;
}
else if(e=='R'){
pgx+=1;
}
else if(e=='F'){
pgy+=1;
}
else if(e=='B'){
pgy-=1;
}
if(abs(gx-pgx)*abs(gx-pgx)+abs(gy-pgy)*abs(gy-pgy)<mi) mi = abs(gx-pgx)*abs(gx-pgx)+abs(gy-pgy)*abs(gy-pgy);
}
return(mi);
}
long long vec(long long mik){
pgy=gy+mik*tgy;
pgx=gx+mik*tgx;
ma=0;
for(int i = 0; i<pu.size(); i++){
e=pu[i];
if(e=='L'){
pgx-=1;
}
else if(e=='R'){
pgx+=1;
}
else if(e=='F'){
pgy+=1;
}
else if(e=='B'){
pgy-=1;
}
if(abs(gx-pgx)*abs(gx-pgx)+abs(gy-pgy)*abs(gy-pgy)>ma) ma = abs(gx-pgx)*abs(gx-pgx)+abs(gy-pgy)*abs(gy-pgy);
}
return(ma);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
cin>>pu;
cin>>lx>>ly>>gx>>gy;
tgx=gx;pgx=gx;pgy=gy;tgy=gy;
mi= INT_MAX;
ma=0;
int siz;
char e;
for(int i = 0; i<pu.size(); i++){
e=pu[i];
if(e=='L'){
tgx-=1;
}
else if(e=='R'){
tgx+=1;
}
else if(e=='F'){
tgy+=1;
}
else if(e=='B'){
tgy-=1;
}
}
tgx-=gx;
tgy-=gy;
mi=INT_MAX;
ma=max(vec(0),vec(n-1));
lo=0;
up=n;
mid=n/2;
while(1==1){
if(naj(mid)<=naj(mid+1)){
if(naj(mid)>=naj(mid-1)){
break;
}
else{
up=mid;
mid=(lo+up)/2;
}
}
else{
lo=mid;
mid=(lo+up)/2;
}
}
mi=naj(mid);
siz=k.size();
cout<<fixed;
cout<<setprecision(12);
cout<<sqrt(mi)<<' '<<sqrt(ma);
}
Compilation message
expgorl.cpp: In function 'long long int naj(long long int)':
expgorl.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i = 0; i<pu.size(); i++){
| ~^~~~~~~~~~
expgorl.cpp: In function 'long long int vec(long long int)':
expgorl.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 0; i<pu.size(); i++){
| ~^~~~~~~~~~
expgorl.cpp: In function 'int main()':
expgorl.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i = 0; i<pu.size(); i++){
| ~^~~~~~~~~~
expgorl.cpp:63:6: warning: variable 'siz' set but not used [-Wunused-but-set-variable]
63 | int siz;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |