Submission #162564

# Submission time Handle Problem Language Result Execution time Memory
162564 2019-11-08T19:20:37 Z dolphingarlic Laugh Analysis (IOI16_laugh) C++14
0 / 100
2 ms 376 KB
#include "laugh.h"

int longest_laugh(std::string s) {
    int ans = 0, curr = 0;
    for (int i = 0; i < s.size(); i++) {
        if ((s[i] == 'a' && (i == 0 || s[i - 1] == 'h')) || (s[i] == 'h' && (i == 0 || s[i - 1] == 'a'))) curr++;
        else curr = 0;
        ans = (ans > curr ? ans : curr);
    }
    return ans;
}

Compilation message

laugh.cpp: In function 'int longest_laugh(std::__cxx11::string)':
laugh.cpp:5:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB numbers differ - expected: '2', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB numbers differ - expected: '2', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB numbers differ - expected: '2', found: '1'
3 Halted 0 ms 0 KB -