fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector<string> split_string(string);
  6.  
  7. /*
  8.  * Complete the taskScheduling function below.
  9.  */
  10. int taskScheduling(int d, int m) {
  11. /*
  12.   * Write your code here.
  13.   */
  14.  
  15. }
  16.  
  17. int main()
  18. {
  19. ofstream fout(getenv("OUTPUT_PATH"));
  20.  
  21. int t;
  22. cin >> t;
  23. cin.ignore(numeric_limits<streamsize>::max(), '\n');
  24.  
  25. for (int t_itr = 0; t_itr < t; t_itr++) {
  26. string dm_temp;
  27. getline(cin, dm_temp);
  28.  
  29. vector<string> dm = split_string(dm_temp);
  30.  
  31. int d = stoi(dm[0]);
  32.  
  33. int m = stoi(dm[1]);
  34.  
  35. int result = taskScheduling(d, m);
  36.  
  37. fout << result << "\n";
  38. }
  39.  
  40. fout.close();
  41.  
  42. return 0;
  43. }
  44.  
  45. vector<string> split_string(string input_string) {
  46. string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
  47. return x == y and x == ' ';
  48. });
  49.  
  50. input_string.erase(new_end, input_string.end());
  51.  
  52. while (input_string[input_string.length() - 1] == ' ') {
  53. input_string.pop_back();
  54. }
  55.  
  56. vector<string> splits;
  57. char delimiter = ' ';
  58.  
  59. size_t i = 0;
  60. size_t pos = input_string.find(delimiter);
  61.  
  62. while (pos != string::npos) {
  63. splits.push_back(input_string.substr(i, pos - i));
  64.  
  65. i = pos + 1;
  66. pos = input_string.find(delimiter, i);
  67. }
  68.  
  69. splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
  70.  
  71. return splits;
  72. }
  73.  
Success #stdin #stdout 0s 5016KB
stdin
Standard input is empty
stdout
Standard output is empty