CSES - Datatähti 2019 loppu - Results
Submission details
Task:Bittijono
Sender:Valtteri Aurela
Submission time:2019-01-17 12:13:44 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<luku.size();i++){
                 ~^~~~~~~~~~~~
input/code.cpp:20:16: error: expected initializer before '++' token
     int counter++;
                ^~
input/code.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<luku.size();i++){
                 ~^~~~~~~~~~~~
input/code.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=i;j<luku.size();j++){
                     ~^~~~~~~~~~~~
input/code.cpp:24:17: error: 'counter' was not declared in this scope
                 counter++;
                 ^~~~~~~
input/code.cpp:24:17: note: suggested alternative: 'toupper'
                 counter++;
                 ^~~~~~~
                 toupper

Code

#include<bits/stdc++.h>
using namespace std;

string luku;
vector<int> su;
int main(){
    cin >> luku;
    if(luku[0]=='1'){
        su.push_back(1);
    }else{
        su.push_back(0);
    }
    for(int i=1;i<luku.size();i++){
        if(luku[i] == '1'){
            su.push_back(su[i-1]+1);
        }else{
            su.push_back(su[i-1]);
        }
    }
    int counter++;
    for(int i=0;i<luku.size();i++){
        for(int j=i;j<luku.size();j++){
            if((su[j]-su[i-1])%2 == 0){
                counter++;
            }
        }
    }
}