Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Marin and Photoshoot codeforces solution in c++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#define ll long long
using namespace std;

void solve()
{
	//A. Marin and Photoshoot

	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '0' && s[i + 1] == '0')
			cnt += 2;
		else if (s[i] == '0' && s[i + 1] == '1' && s[i + 2] == '0')
			cnt += 1;
	}
	cout << cnt << "
";
}

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: ue_log example 
Cpp :: two dimensional matrix using oops concept 
Cpp :: c++ to c converter online 
Cpp :: c++ program 
Cpp :: glm multiply vector by scalar 
Cpp :: composition namespaces c++ 
Cpp :: convert preorder to postorder calculator 
Cpp :: test3 
Cpp :: convert "c++ to c" code online 
Cpp :: split the array there is an array val of n integers . A good subarray is defined as 
Cpp :: Hiring Test codechef solution in c++ 
Cpp :: c++ vector merge algorithm 
Cpp :: In-range Adder 
Cpp :: this is my p phone number in punjabi 
Cpp :: temporary variable ex c++ 
Cpp :: ++i v.s i++ 
Cpp :: polymorphism c++ virtual 
Cpp :: 2dvector c++ 
Cpp :: initializer before void c++ 
Cpp :: beecrowd problem 1001 solution 
Cpp :: Max / Min Stack in c++ using stl in O(1) time and space 
Cpp :: search in vector of pairs c++ 
Cpp :: delete a head node in link list 
Cpp :: what do we use c++ vectors for 
Cpp :: program to check smallest num in three numbers in c++ 
Cpp :: qregexpvalidator qlineedit email address 
C :: c distance between 2 points 
C :: adb switch to usb 
C :: come creare variabili casuali in c 
C :: reverse integer in c 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =