Rezultati

Up. imeNalogaJezikRezultatČas oddaje
PIN Hodnik C++ 100/100OK 20. apr '17 @ 17:37

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

Ocenjevani program (hallway.cpp):
#include <iostream>
#include <vector>
#include <math.h>
#include <string>

using namespace std;

int main()
{    
    string lights;

    cin >> lights;

    if(lights.size() <= 1)
    {
        cout << 0 << endl;
        return 0;
    }

//    char lastState = lights[0];
    int ctrStarting0 = 0, ctrStarting1 = 0;


    for(int i = 0; i < lights.size(); i++)
    {
        //cout << i << ":" << endl;
        if(i % 2 == 0)
        {
            //cout << "i % 2 == 0"<< endl;
            if(lights[i] == '0')
            {
                //cout << "INCR 1" << endl;
                ctrStarting1++;
            }
            else
            {
              //  cout << "INCR 0" << endl;
                ctrStarting0++;
            }
        }
        if(i % 2 == 1)
        {
            //cout << "i % 2 == 1"<< endl;
            if(lights[i] == '1')
            {
                //cout << "INCR 1" << endl;
                ctrStarting1++;
            }
            else
            {
               // cout << "INCR 0" << endl;
                ctrStarting0++;
            }
        }
        
    }

    

    cout << (ctrStarting0 < ctrStarting1 ? ctrStarting0 : ctrStarting1) << endl;

    return 0;
}