Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 14:25:34
2016-05-28 12:26:32
Task:Bit strings
Sender:ContinuedLife
Submission time:2016-05-28 14:25:34
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int right = left + 1; right < str.size(); ++right){
                                               ^
input/code.cpp:23:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i =0; i < ans.size(); ++i){
                              ^

Code

#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(6);

using namespace std;

#define maxN 1e5
int main(){ _
	int TC;	cin >> TC;
	while(TC--){
		string str;	cin >> str;
		vector<int> ans(str.size()+1, 0);
		//cout << str.size() << endl;
		for(int left = -1; left < int(str.size()); ++left){
//				cout << "get here> " << endl;
			int acc = 0;
			for(int right = left + 1; right < str.size(); ++right){
//				cout << str[right] << " ";
//				cout << "get here> " << endl;
				if(str[right] == '1'){	++acc;	}
				ans[acc] += 1;
			}
		}
		for(int i =0; i < ans.size(); ++i){
			if(i)	cout << " ";
			cout << ans[i];
		}	cout << endl;
				
	}
		

	return 0;
}