Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector<string> split_string(string);
  6.  
  7. string chessboardGame(int x, int y)
  8. {
  9. if((x==1 || x==2 || x==5 || x==6 || x==9 || x==10 || x==13 || x==14) && (y==1 || y==2 || y==5 || y==6 || y==9 || y==10 || y==13 || y==14))
  10. {
  11. return "Second";
  12. }
  13. return "First";
  14. }
  15.  
  16. int main()
  17. {
  18. ofstream fout(getenv("OUTPUT_PATH"));
  19.  
  20. int t;
  21. cin >> t;
  22. cin.ignore(numeric_limits<streamsize>::max(), '\n');
  23.  
  24. for (int t_itr = 0; t_itr < t; t_itr++) {
  25. string xy_temp;
  26. getline(cin, xy_temp);
  27.  
  28. vector<string> xy = split_string(xy_temp);
  29.  
  30. int x = stoi(xy[0]);
  31.  
  32. int y = stoi(xy[1]);
  33.  
  34. string result = chessboardGame(x, y);
  35.  
  36. fout << result << "\n";
  37. }
  38.  
  39. fout.close();
  40.  
  41. return 0;
  42. }
  43.  
  44. vector<string> split_string(string input_string) {
  45. string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
  46. return x == y and x == ' ';
  47. });
  48.  
  49. input_string.erase(new_end, input_string.end());
  50.  
  51. while (input_string[input_string.length() - 1] == ' ') {
  52. input_string.pop_back();
  53. }
  54.  
  55. vector<string> splits;
  56. char delimiter = ' ';
  57.  
  58. size_t i = 0;
  59. size_t pos = input_string.find(delimiter);
  60.  
  61. while (pos != string::npos) {
  62. splits.push_back(input_string.substr(i, pos - i));
  63.  
  64. i = pos + 1;
  65. pos = input_string.find(delimiter, i);
  66. }
  67.  
  68. splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
  69.  
  70. return splits;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement