Submission #287815

#TimeUsernameProblemLanguageResultExecution timeMemory
287815tinjyuLaugh Analysis (IOI16_laugh)C++14
100 / 100
6 ms1408 KiB
#include "laugh.h" #include <iostream> using namespace std; long long int dp[100005]; int longest_laugh(std::string s) { for(int i=0;i<s.length();i++) { if(s[i]=='a') { if(i>0 && s[i-1]=='h')dp[i]=dp[i-1]+1; else dp[i]=1; } if(s[i]=='h') { if(i>0 && s[i-1]=='a')dp[i]=dp[i-1]+1; else dp[i]=1; } } long long int ans=0; for(int i=0;i<s.length();i++)ans=max(ans,dp[i]); return ans; }

Compilation message (stderr)

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