답안 #51584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51584 2018-06-18T22:22:44 Z MatheusLealV Laugh Analysis (IOI16_laugh) C++17
100 / 100
7 ms 2584 KB
#include "laugh.h"
#include <bits/stdc++.h>

using namespace std;

int longest_laugh(string s)
{
	int ans = 0, prev = -1;

	char p;

    for(int i = 0; i < s.size(); i++)
    {
    	if(s[i] != 'h' and s[i] != 'a') continue;

    	int st = i;

    	p = (s[i] == 'h' ? 'a' : 'h');

    	i ++;

    	while(i < s.size() and s[i] == p)
    	{
    		i ++;

    		if(p == 'h') p = 'a';

    		else p = 'h';
    	}

    	ans = max(ans, i - st);

    	i --;
    }

    return ans;
}

Compilation message

laugh.cpp: In function 'int longest_laugh(std::__cxx11::string)':
laugh.cpp:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < s.size(); i++)
                    ~~^~~~~~~~~~
laugh.cpp:22:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      while(i < s.size() and s[i] == p)
            ~~^~~~~~~~~~
laugh.cpp:8:15: warning: unused variable 'prev' [-Wunused-variable]
  int ans = 0, prev = -1;
               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 2 ms 764 KB Output is correct
19 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 2 ms 764 KB Output is correct
19 Correct 2 ms 764 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 792 KB Output is correct
22 Correct 2 ms 928 KB Output is correct
23 Correct 2 ms 928 KB Output is correct
24 Correct 2 ms 948 KB Output is correct
25 Correct 2 ms 948 KB Output is correct
26 Correct 3 ms 948 KB Output is correct
27 Correct 2 ms 948 KB Output is correct
28 Correct 2 ms 948 KB Output is correct
29 Correct 3 ms 948 KB Output is correct
30 Correct 2 ms 996 KB Output is correct
31 Correct 2 ms 1020 KB Output is correct
32 Correct 2 ms 1020 KB Output is correct
33 Correct 3 ms 1020 KB Output is correct
34 Correct 2 ms 1072 KB Output is correct
35 Correct 2 ms 1072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 2 ms 764 KB Output is correct
19 Correct 2 ms 764 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 792 KB Output is correct
22 Correct 2 ms 928 KB Output is correct
23 Correct 2 ms 928 KB Output is correct
24 Correct 2 ms 948 KB Output is correct
25 Correct 2 ms 948 KB Output is correct
26 Correct 3 ms 948 KB Output is correct
27 Correct 2 ms 948 KB Output is correct
28 Correct 2 ms 948 KB Output is correct
29 Correct 3 ms 948 KB Output is correct
30 Correct 2 ms 996 KB Output is correct
31 Correct 2 ms 1020 KB Output is correct
32 Correct 2 ms 1020 KB Output is correct
33 Correct 3 ms 1020 KB Output is correct
34 Correct 2 ms 1072 KB Output is correct
35 Correct 2 ms 1072 KB Output is correct
36 Correct 5 ms 1232 KB Output is correct
37 Correct 6 ms 1260 KB Output is correct
38 Correct 5 ms 1276 KB Output is correct
39 Correct 5 ms 1480 KB Output is correct
40 Correct 6 ms 1560 KB Output is correct
41 Correct 7 ms 1752 KB Output is correct
42 Correct 6 ms 1752 KB Output is correct
43 Correct 5 ms 1752 KB Output is correct
44 Correct 5 ms 1880 KB Output is correct
45 Correct 7 ms 1984 KB Output is correct
46 Correct 6 ms 2084 KB Output is correct
47 Correct 5 ms 2184 KB Output is correct
48 Correct 6 ms 2288 KB Output is correct
49 Correct 6 ms 2384 KB Output is correct
50 Correct 6 ms 2484 KB Output is correct
51 Correct 6 ms 2584 KB Output is correct