답안 #710054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710054 2023-03-15T04:10:09 Z ToroTN Laugh Analysis (IOI16_laugh) C++14
컴파일 오류
0 ms 0 KB
#include "laugh.h"
#include<bits/stdc++.h>
#include "grader.cpp"
using namespace std;
#define pb push_back
int cnt;
map<char,char> mp;
int longest_laugh(std::string s)
{
    mp['h']='a';
    mp['a']='h';
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h'||s[i]=='a')
        {
            if(i==0||s[i-1]!='h'&&s[i-1]!='a')
            {
                cnt=1;
            }else
            {
                if(s[i]==mp[s[i-1]])
                {
                    ++cnt;
                }else
                {
                    cnt=1;
                }
            }
        }else
        {
            cnt=0;
        }
        ans=max(ans,cnt);
    }
    return ans;
}

Compilation message

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
laugh.cpp:17:33: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   17 |             if(i==0||s[i-1]!='h'&&s[i-1]!='a')
/usr/bin/ld: /tmp/ccCF2CKw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc9p0BOs.o:laugh.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status