CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:jusola
Submission time:2019-10-02 21:12:39 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'std::__cxx11::string toFormat(std::__cxx11::string)':
input/code.cpp:69:2: error: 'strcpy' was not declared in this scope
  strcpy(arrStr, in.c_str());
  ^~~~~~
input/code.cpp:69:2: note: suggested alternative: 'strtoq'
  strcpy(arrStr, in.c_str());
  ^~~~~~
  strtoq
input/code.cpp: In function 'int main()':
input/code.cpp:89:2: error: 'strcpy' was not declared in this scope
  strcpy(alphabetArr, alphabet.c_str());
  ^~~~~~
input/code.cpp:89:2: note: suggested alternative: 'strtoq'
  strcpy(alphabetArr, alphabet.c_str());
  ^~~~~~
  strtoq

Code

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>

using namespace std;

const string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

char alphabetArr[54];



/*
bool isPair(const string a = 0, const string b = 0) {
	std::unordered_map<char, char> mapA;
	std::unordered_map<char, char> mapB;

	std::unordered_map<char, char>::iterator it;

	char arrA[50];
	char arrB[50];

	string newA;
	string newB;

	strcpy_s(arrA, a.c_str());
	strcpy_s(arrB, b.c_str());

	for (int i = 0; i < (int)a.size(); i++) {
		if (mapA.find(arrA[i]) != mapA.end()) {
			newA = newA + std::string(1, mapA.find(arrA[i])->second);
		}
		else {
			newA = newA + std::string(1, alphabetArr[(int)mapA.size()]);
			mapA.insert(std::pair<char, char>(arrA[i], alphabetArr[(int)mapA.size()]));

		}

	}

	for (int i = 0; i < (int)b.size(); i++) {
		if (mapB.find(arrB[i]) != mapB.end()) {
			newB = newB + std::string(1, mapB.find(arrB[i])->second);
		}
		else {
			newB = newB + std::string(1, alphabetArr[(int)mapB.size()]);
			mapB.insert(std::pair<char, char>(arrB[i], alphabetArr[(int)mapB.size()]));

		}

	}
	return (newA == newB);
}
*/

string toFormat(const string in) {
	std::unordered_map<char, char> mapStr;

	std::unordered_map<char, char>::iterator it;

	char arrStr[50];

	string newStr;

	strcpy(arrStr, in.c_str());

	for (int i = 0; i < (int)in.size(); i++) {
		if (mapStr.find(arrStr[i]) != mapStr.end()) {
			newStr = newStr + std::string(1, mapStr.find(arrStr[i])->second);
		}
		else {
			newStr = newStr + std::string(1, alphabetArr[(int)mapStr.size()]);
			mapStr.insert(std::pair<char, char>(arrStr[i], alphabetArr[(int)mapStr.size()]));

		}

	}

	return newStr;
}

int main() {
	int num;
	int amount = 0;
	strcpy(alphabetArr, alphabet.c_str());
	string arr[5000];
	string newArr[5000];
	cin >> num;

	for (int i = 0; i < num; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < num; i++) {
		newArr[i] = toFormat(arr[i]);
	};

	for (int i = 0; i < num; i++)
	{
		for (int j = i + 1; j < num; j++)
		{
			if (newArr[i] == newArr[j])
			{
				amount++;
				break;
			}
		}
	}
	cout << amount;
	return 0;
}