Submission #969899

#TimeUsernameProblemLanguageResultExecution timeMemory
969899marinalucaLaugh Analysis (IOI16_laugh)C++14
100 / 100
2 ms856 KiB
#include "laugh.h"
#include <bits/stdc++.h>
#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")

using namespace std;
//#define int long long
#define ll long long
#define xx first
#define yy second
#define all (x) begin (x), end (x)
/**
#define cin fin
#define cout fout

ifstream cin ("paresort.in");
ofstream cout ("paresort.out");
**/
int longest_laugh (string s){
    int cnt = 0, maxi = 0;
    for (int i = 0; i < s.size(); ++ i){
        if (s[i] == 'a' || s[i] == 'h'){
            cnt ++;
            if (i && s[i] == s[i - 1])
                cnt = 1;
            maxi = max (maxi, cnt);
        }
        else
            cnt = 0;
    }
    return maxi;
}

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < s.size(); ++ i){
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...