Submission #89035

# Submission time Handle Problem Language Result Execution time Memory
89035 2018-12-10T08:48:41 Z tamazineb Experiments with Gorlum (IZhO13_expgorl) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
int n,mx;
int a[1],b[1];
double j=1000000,p=-1;
cin>>n;
string s;
cin>>s;
cin>>a[0]>>a[1];
cin>>b[0]>>b[1];
for(int w=0;w<=n;w++){
for(int k=0;k<s.size();k++){
   if(s[k]=='L') {
    b[0]--;
    mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));

   }
   if(s[k]=='R'){
    b[0]++;
 mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));   }
    if(s[k]=='F'){
       b[1]++;
 mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));

    }
    if(s[k]=='B'){
        b[1]--;
 mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));    }
    if(s[k]=='I'){
 mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
    }

 if(mx>p)
 p=mx;

 if(mx<j)
    j=mx;
}
}

cout<<fixed<<setprecision(12)<<j<<" ";
cout<<fixed<<setprecision(12)<<p;
    return 0;

}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:15:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(int k=0;k<s.size();k++){
             ~^~~~~~~~~
expgorl.cpp:18:41: warning: array subscript is above array bounds [-Warray-bounds]
     mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
                                      ~~~^
expgorl.cpp:18:46: warning: array subscript is above array bounds [-Warray-bounds]
     mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
                                           ~~~^
expgorl.cpp:23:38: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));   }
                                   ~~~^
expgorl.cpp:23:43: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));   }
                                        ~~~^
expgorl.cpp:25:11: warning: array subscript is above array bounds [-Warray-bounds]
        b[1]++;
        ~~~^
expgorl.cpp:25:11: warning: array subscript is above array bounds [-Warray-bounds]
expgorl.cpp:26:38: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
                                   ~~~^
expgorl.cpp:30:12: warning: array subscript is above array bounds [-Warray-bounds]
         b[1]--;
         ~~~^
expgorl.cpp:30:12: warning: array subscript is above array bounds [-Warray-bounds]
expgorl.cpp:31:38: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));    }
                                   ~~~^
expgorl.cpp:33:38: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
                                   ~~~^
expgorl.cpp:33:43: warning: array subscript is above array bounds [-Warray-bounds]
  mx=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]));
                                        ~~~^
expgorl.cpp:36:7: warning: 'mx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mx>p)
     ~~^~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -