답안 #168905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168905 2019-12-17T04:48:16 Z abil 생물 실험 (IZhO13_expgorl) C++14
0 / 100
175 ms 376 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

int lx, ly;
double ansmin, ansmax;
double dist(double x, double y){
	return sqrt((x - lx) * (x - lx) + (y - ly) * (y - ly)); 
}

string s;
double gx, gy, x = 0, y = 0;
void check(int val){
	double gxx = gx + val * x, gyy = gy + val * y;
	ansmin = min(ansmin, dist(gxx, gyy));
	ansmax = max(ansmax, dist(gxx, gyy));
	for(int i = 0;i < s.size(); i++){
		if(s[i] == 'L'){
			gxx--;
		}
		if(s[i] == 'R'){
			gxx++;
		}
		if(s[i] == 'F'){
			gyy++;
		}
		if(s[i] == 'B'){
			gyy--;
		}
		ansmin = min(ansmin, dist(gxx, gyy));
		ansmax = max(ansmax, dist(gxx, gyy));
	}
}
main()
{
	int k;
	scanf("%d", &k);
	cin >> s;
	cin >> lx >> ly;
	cin >> gx >> gy;
	ansmin = dist(gx, gy), ansmax = dist(gx, gy);
	for(int i = 0;i < s.size(); i++){
		if(s[i] == 'L'){
			x--;
		}
		if(s[i] == 'R'){
			x++;
		}
		if(s[i] == 'F'){
			y++;
		}
		if(s[i] == 'B'){
			y--;
		}
	}
	for(int i = 0;i <= min(k, 10000); i++){
		check(i);
	}
	for(int i = max(10001, k - 10000);i <= k; i++){
		check(i);
	}
	cout << fixed << setprecision(9) << ansmin << " " << ansmax;
}

Compilation message

expgorl.cpp: In function 'void check(int)':
expgorl.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i < s.size(); i++){
                ~~^~~~~~~~~~
expgorl.cpp: At global scope:
expgorl.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
expgorl.cpp: In function 'int main()':
expgorl.cpp:53:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i < s.size(); i++){
                ~~^~~~~~~~~~
expgorl.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 175 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -