Submission #957511

#TimeUsernameProblemLanguageResultExecution timeMemory
957511hirayuu_ojLaugh Analysis (IOI16_laugh)C++17
100 / 100
4 ms1624 KiB
#include "laugh.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,l,r) for(int i=(l); i<(r); i++) #define all(x) x.begin(),x.end(); using ll = long long; int longest_laugh(std::string s){ vector<ll> dp(s.size()); ll ans=0; rep(i,s.size()){ if(s[i]=='a'){ if(i!=0 and s[i-1]=='h'){ dp[i]=dp[i-1]+1; } else{ dp[i]=1; } } else if(s[i]=='h'){ if(i!=0 and s[i-1]=='a'){ dp[i]=dp[i-1]+1; } else{ dp[i]=1; } } else{ dp[i]=0; } ans=max(ans,dp[i]); } return ans; }

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:4:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
laugh.cpp:12:5: note: in expansion of macro 'rep'
   12 |     rep(i,s.size()){
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...