Submission #926389

#TimeUsernameProblemLanguageResultExecution timeMemory
926389rainboyLaugh Analysis (IOI16_laugh)C11
100 / 100
1 ms604 KiB
#include "laugh_c.h"
#include <string.h>

int max(int a, int b) { return a > b ? a : b; }

int longest_laugh(char *cc) {
	int n, i, j, k;
	char c;
	
	n = strlen(cc);
	k = 0;
	for (i = 0; i < n; i++)
		if (cc[i] == 'a' || cc[i] == 'h') {
			c = cc[i];
			j = i;
			while (j < n && cc[j] == c)
				j++, c = c == 'a' ? 'h' : 'a';
			k = max(k, j - i);
			i = j - 1;
		}
	return k;
}

Compilation message (stderr)

grader.c: In function 'main':
grader.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%s", s);
      |  ^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...