CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:nagrodus
Submission time:2015-10-01 17:06:57 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:17:24: error: 'memset' was not declared in this scope
  memset(t, 0, sizeof(t));
                        ^
input/code.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < str.length(); i++){
                    ^

Code

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

#define RANGE 26

using namespace std;

int main(int argc, char* argv[])
{
	ios_base::sync_with_stdio(0);
	string str;
	int c = 0;
	int t[RANGE];
	cin >> str;
	memset(t, 0, sizeof(t));
	for (int i = 0; i < str.length(); i++){
		t[str[i] - 'A']++;
		c += t[str[i] - 'A'];
	}
	cout << c;
	return 0;
}