Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- vector<string> split_string(string);
- string solve(int r1, int r2, vector<int> position, vector<int> acceleration) {
- double t;
- double deltaX=(double)position[0];
- cout <<r1<< " " << r2<< " "<< position[0]<<position[1]<<position[2] << endl;
- cout << acceleration[0]<<acceleration[1]<<acceleration[2] << endl;
- double deltaY=(double)position[1];
- double deltaZ=(double)position[2];
- double accX = (double)acceleration[0];
- double accY = (double)acceleration[1];
- double accZ = (double)acceleration[2];
- double numerador = abs(2.0 * (deltaX*accX + deltaY*accY + deltaZ*accZ));
- double denominador = accX*accX+accY*accY+accZ*accZ;
- t=sqrt(numerador/denominador);
- double S = deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ + 2*(deltaX*accX+deltaY*accY+deltaZ*accZ)*t*t/2.0 + denominador*t*t*t*t/4.0;
- if(S<=(r1+r2)*(r1+r2))return "YES";
- return "NO";
- }
- int main()
- {
- ofstream fout(getenv("OUTPUT_PATH"));
- int t;
- cin >> t;
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- for (int t_itr = 0; t_itr < t; t_itr++) {
- string r1R2_temp;
- getline(cin, r1R2_temp);
- vector<string> r1R2 = split_string(r1R2_temp);
- int r1 = stoi(r1R2[0]);
- int r2 = stoi(r1R2[1]);
- string position_temp_temp;
- getline(cin, position_temp_temp);
- //1
- vector<string> position_temp = split_string(position_temp_temp);
- vector<int> position(3);
- for (int i = 0; i < 3; i++) {
- int position_item = stoi(position_temp[i]);
- position[i] = position_item;
- }
- string acceleration_temp_temp;
- getline(cin, acceleration_temp_temp);
- vector<string> acceleration_temp = split_string(acceleration_temp_temp);
- vector<int> acceleration(3);
- for (int i = 0; i < 3; i++) {
- int acceleration_item = stoi(acceleration_temp[i]);
- acceleration[i] = acceleration_item;
- }
- //2
- string position_temp_temp2;
- getline(cin, position_temp_temp2);
- vector<string> position_temp2 = split_string(position_temp_temp2);
- for (int i = 0; i < 3; i++) {
- int position_item = stoi(position_temp2[i]);
- position[i] = position_item - position[i];
- }
- string acceleration_temp_temp2;
- getline(cin, acceleration_temp_temp2);
- vector<string> acceleration_temp2 = split_string(acceleration_temp_temp2);
- for (int i = 0; i < 3; i++) {
- int acceleration_item2 = stoi(acceleration_temp2[i]);
- acceleration[i] = acceleration_item2 - acceleration[i];
- }
- string result = solve(r1, r2, position, acceleration);
- fout << result << "\n";
- }
- fout.close();
- return 0;
- }
- vector<string> split_string(string input_string) {
- string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
- return x == y and x == ' ';
- });
- input_string.erase(new_end, input_string.end());
- while (input_string[input_string.length() - 1] == ' ') {
- input_string.pop_back();
- }
- vector<string> splits;
- char delimiter = ' ';
- size_t i = 0;
- size_t pos = input_string.find(delimiter);
- while (pos != string::npos) {
- splits.push_back(input_string.substr(i, pos - i));
- i = pos + 1;
- pos = input_string.find(delimiter, i);
- }
- splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
- return splits;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement