Submission #338088

#TimeUsernameProblemLanguageResultExecution timeMemory
338088KerimExperiments with Gorlum (IZhO13_expgorl)C++17
100 / 100
9 ms536 KiB
#include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} double lx,ly,gx,gy,tx,ty; int n,k; char s[MAXN]; double dis(double x,double y){ return sqrt((x-lx)*(x-lx)+(y-ly)*(y-ly)); } double f1(int a){ double x=gx+a*tx; double y=gy+a*ty; double res=dis(x,y); for(int i=0;i<n;i++){ if(s[i]=='L') x--; else if(s[i]=='R') x++; else if(s[i]=='F') y++; else if(s[i]=='B') y--; umin(res,dis(x,y)); }return res; } double mn(){ int st=0,en=k-1; while(st+1<en){ int mid=(st+en)>>1; if(f1(mid)<f1(mid+1)) en=mid; else st=mid; } return min(f1(st),f1(en)); } double f2(int a){ double x=gx+a*tx; double y=gy+a*ty; double res=dis(x,y); for(int i=0;i<n;i++){ if(s[i]=='L') x--; else if(s[i]=='R') x++; else if(s[i]=='F') y++; else if(s[i]=='B') y--; umax(res,dis(x,y)); }return res; } double mx(){ int st=0,en=k-1; while(st+1<en){ int mid=(st+en)>>1; if(f2(mid)>f2(mid+1)) en=mid; else st=mid; } return max(f2(st),f2(en)); } int main(){ //freopen("file.in", "r", stdin); scanf("%d",&k); scanf("%s",s);n=strlen(s); cin>>lx>>ly>>gx>>gy; for(int i=0;i<n;i++){ if(s[i]=='L') tx--; else if(s[i]=='R') tx++; else if(s[i]=='F') ty++; else if(s[i]=='B') ty--; } printf("%.12lf %.12lf\n",mn(),mx()); return 0; }

Compilation message (stderr)

expgorl.cpp: In function 'int main()':
expgorl.cpp:82:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   82 |     scanf("%d",&k);
      |     ~~~~~^~~~~~~~~
expgorl.cpp:83:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   83 |     scanf("%s",s);n=strlen(s);
      |     ~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...