Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 13:24:41
Task:HIIT Generation
Sender:DualCore
Submission time:2018-05-26 13:24:41
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Code

#include <iostream>
#include <string>

void replace(std::string& str, char c)
{
  std::string ret;
  ret.reserve(1000000);
  for (unsigned int i = 0; i < str.length(); ++i)
    {
      if (str[i] == c)
	ret = ret + "HIIT";
      else
	ret.push_back(str[i]);
    }
  str = ret;
}

int main()
{
  std::string first_line;
  int n;
  std::getline(std::cin, first_line);
  n = std::stoi(first_line);
  std::string HIIT = "HIIT";
  for (int i = 0; i < n; ++i)
    {
      std::string line;
      std::getline(std::cin, line);
      char c = line[0];
      replace(HIIT, c);
    }
  std::cout << HIIT;
}