답안 #957155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957155 2024-04-03T05:30:58 Z ALTAKEXE Laugh Analysis (IOI16_laugh) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int longest_laugh(string s)
{
    int ans = 0, mx = 0;
    for (int i = 0; i < s.size(); i++)
    {
        mx = max(ans, mx);
        if (s[i] == 'a')
            ans++;
        if (s[i] == 'h' && s[i - 1] == 'a' || s[i + 1] == 'a')
            ans++;
        if (s[i] != 'a' && s[i] != 'h')
            ans = 0;
    }
    return mx;
}

Compilation message

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:6:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for (int i = 0; i < s.size(); i++)
      |                     ~~^~~~~~~~~~
laugh.cpp:11:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   11 |         if (s[i] == 'h' && s[i - 1] == 'a' || s[i + 1] == 'a')
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '12'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '12'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '12'
3 Halted 0 ms 0 KB -