제출 #957155

#제출 시각아이디문제언어결과실행 시간메모리
957155ALTAKEXELaugh Analysis (IOI16_laugh)C++14
0 / 100
1 ms348 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

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')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...