#include <bits/stdc++.h>
using namespace std;
#define int long long
int longest_laugh(string s){
int cur= 0, ans=0,prev=2,n=s.size();
// bool rn = true;
if (s[0] == 'h'){
cur = 1;
ans = 1;
prev = 1;
}
if (s[0] == 'a'){
cur = 1;
ans = 1;
prev = 0;
}
for (int i = 1; i < n; i++){
if (s[i] == 'a'){
if (prev == 0){
cur = 0;
}
else {
cur++;
ans = max(ans,cur);
}
prev = 0;
}
else if (s[i] == 'h'){
if (prev == 1){
cur = 0;
}
else {
cur++;
ans = max(ans,cur);
}
prev = 1;
}
else {
cur = 0;
prev = 2;
}
// cout << cur << " " << ans << " " << prev << "\n";
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |