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 15:32:44
2018-05-26 15:20:45
2018-05-26 15:18:10
2018-05-26 11:59:01
2018-05-26 11:56:08
2018-05-26 11:37:36
2018-05-26 11:37:12
Task:HIIT Generation
Sender:El Numero Uno
Submission time:2018-05-26 15:32:44
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < f.size(); i++) {
                         ~~^~~~~~~~~~

Code

#include <iostream>
#include "stdio.h"

using namespace std;

int main() {
    char c;
    int n;
    cin >> n;
    string s = "HIIT";
    string f = "HIIT";
    string t = "";
    f.reserve(1000000);
    for (int _ = 0; _ < n; _++) {
        cin >> c;
        t = "";
        for (int i = 0; i < f.size(); i++) {
            if (f[i] == c) {
                t += s;
            }
            else {
                t += f[i];
            }
        }
        f = t;

    }
    printf("%s\n", f.c_str());
    return 0;
}