Rezultati

Up. imeNalogaJezikRezultatČas oddaje
undefined-2017 Hodnik C++ 100/100OK 20. apr '17 @ 17:12

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,059 MiB 0,004 s OK
#2 10/10 3,105 MiB 0,004 s OK
#3 10/10 3,117 MiB 0,004 s OK
#4 10/10 3,117 MiB 0,004 s OK
#5 10/10 3,113 MiB 0,004 s OK
#6 10/10 3,129 MiB 0,004 s OK
#7 10/10 3,129 MiB 0,004 s OK
#8 10/10 3,121 MiB 0,004 s OK
#9 10/10 3,121 MiB 0,004 s OK
#10 10/10 3,129 MiB 0,004 s OK

Ocenjevani program (Source.cpp):
#include <iostream>
#include <string>
#include <unordered_set>
#include <stack>
#include <vector>

bool areCompanions(std::string a, std::string b) {
	return (a.substr(0, 3) == b.substr(0, 3)) || (a.substr(a.length() - 3) == b.substr(b.length() - 3));
}

int main() {
	//freopen("C:\\Users\\matej.drobnic\\Desktop\\testhodnik.txt", "r", stdin);

	int firstZero = 0;
	int firstOne = 0;

	std::string line;

	std::getline(std::cin, line);
	
	char fz = '0';
	for (int i = 0; i < line.length(); i++) {
		if (line[i] == fz) {
			firstZero++;
		}
		else {
			firstOne++;
		}

		fz = fz == '0' ? '1' : '0';
	}

	if (firstZero > firstOne) {
		std::cout << (line.size() - firstZero) << std::endl;
	}
	else {
		std::cout << (line.size() - firstOne) << std::endl;
	}
}