Source Code
#include<string>
#include <iostream>
using namespace std;


int main() {

	int r, c, result = 0, count = 0;
	string a[10][10];
	cin >> r;
	cin >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
		}
	}

	for (int j = 0; j < c; j++)
	{
		for (int i = 0; i < r; i++) 
		{

			if (a[i][j] == "1") {
				count++;
			}
			
			if (count == 1)
				result++;
		}
	}
	cout << result;
	
	/*int n, max = 1;
	cin >> n;
	int a[100000];

	for (int i = 0; i < n; i++)
		cin >> a[i];
	bool f = false;
	for (int i = 0; i < n; i++)
	{

		if (a[i] < 0)
		{
			if (a[i] < max)
				max = a[i];
			f = true;

		}

	}
	if (f)
		cout << abs(max);
	else

		cout << 0;*/

	//long long  n = 0, sum = 0, a[100], num = 0;
	//cin >> n;
	//for (int i = 0; i < n; i++) {
	//	cin >> a[i];
	//	sum = sum + a[i];
	//}
	//if (sum < 10)
	//{
	//	cout << sum;
	//	return 0;
	//}

	//while (sum != 0) {
	//	num = num + (sum % 10);
	//	sum = sum / 10;

	//	//num = num + sum;
	//	if (sum == 0 && num>=10)
	//	{
	//		sum = num;
	//		num = 0;
	//	}


	//}
	//cout << num;

	//long long b = 0;
	//long long  n = 0, sum = 0, a[100], num = 0;
	//cin >> n;
	//for (int i = 0; i < n; i++) 
	//{
	//	cin >> a[i];
	//	while (a[i] != 0) 
	//	{
	//		num = num + (a[i] % 10);
	//		a[i] = a[i] / 10;

	//		//num = num + sum;
	//		if (a[i] == 0 && num >= 10)
	//		{
	//			a[i] = num;
	//			num = 0;
	//		}
	//		
 //        
	//    }
	//	b = b + num;

	//}
	//cout << b;
	




}
Copy
Obada Discovers His Hearing Issues hatamleh
GNU G++17
2 ms
348 KB
Wrong Answer