Rezultati

Up. imeNalogaJezikRezultatČas oddaje
TNT Hodnik C++ 100/100OK 20. apr '17 @ 18:52

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,117 MiB 0,004 s OK
#2 10/10 3,117 MiB 0,004 s OK
#3 10/10 3,121 MiB 0,004 s OK
#4 10/10 3,117 MiB 0,004 s OK
#5 10/10 3,117 MiB 0,004 s OK
#6 10/10 3,121 MiB 0,004 s OK
#7 10/10 3,113 MiB 0,004 s OK
#8 10/10 3,117 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 (Hodnik.cpp):
// Hodnik.cpp : Defines the entry point for the console application.
//
#include <algorithm>
//#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
int stej = 0;
int Stejponovitve(string x)
{
	int N = x.size();
	char nekaj;
	int stevec = 0;
	for (int i = 0; i < N - 1; i++)
	{
		nekaj = x[i];
		bool prvaNiNic = i != 0;
		int stejCrke = 0;
		for (int j = i; j < N; j++)
		{
			if (nekaj == x[j])
				stejCrke++;
			else {
				if (stejCrke % 2 == 0 && prvaNiNic)
					stejCrke += 2;
				i += stejCrke - 1;
				break;
			}
			if (j == N - 1)
				i += stejCrke - 1;
		}
		stevec += stejCrke / 2;
	}
	return stevec;
}
void zamenjaj(char& x) {
	if (x == '0')
		x = '1';
	else
		x = '0';
}
int stejEnake(string vnos, char iskana) {
	int stevec = 0;
	int N = vnos.size();

	for (int i = 0; i < N; i++) {
		if (vnos[i] == iskana)
			stevec++;
		zamenjaj(iskana);
	}
	return stevec;
}
int main()
{
	string vnos;
	//while (true) {
		cin >> vnos;
		int iskanje1 = stejEnake(vnos, '1');
		int iskanje2 = stejEnake(vnos, '0');
		if (iskanje1 > iskanje2)
			cout << iskanje2;
		else
			cout << iskanje1;
	//}
	//return 0;
}