답안 #563182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563182 2022-05-16T12:44:03 Z Kanten4205 Laugh Analysis (IOI16_laugh) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<ll, ll> P;
const long long INF = 1e17;
ll longest_laugh(string S) {
    ll ans = 0, ans2 = 0;
    ll num = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (num % 2 == 0) {
            if (S[i] == 'a') num++;
            else {
                ans = max(ans, num);
                num = 0;
            }
        }
        else {
            if (S[i] == 'h') num++;
            else {
                ans = max(ans, num);
                num = 0;
            }
        }
    }
    ans = max(ans, num);
    num = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (num % 2 == 0) {
            if (S[i] == 'h') num++;
            else {
                ans2 = max(ans2, num);
                num = 0;
            }
        }
        else {
            if (S[i] == 'a') num++;
            else {
                ans2 = max(ans2, num);
                num = 0;
            }
        }
    }
    ans2 = max(ans2, num);
    return max(ans, ans2);
}

Compilation message

laugh.cpp: In function 'll longest_laugh(std::string)':
laugh.cpp:11:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (ll i = 0; i < S.size(); i++) {
      |                    ~~^~~~~~~~~~
laugh.cpp:29:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (ll i = 0; i < S.size(); i++) {
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 -