Blame view

P13623_en/S001-AC.cc 761 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int r,c;
	char* row;

	cin >> r;
	cin >> c;

	if(r < 1 || c < 1)
	{
		cout << 0 << endl;
		return 0;
	}
	char num;
	int count = 0;
	for(int i = 0; i < r; i++)
	{
		if(!(i % 2))
		{
			for(int j = 0; j < c; j++)
			{
				cin >> num;
				if(!(j % 2))
				{
					count += num-48;
				}
			}
		}
		else
		{
			for(int j = 0; j < c; j++)
			{
				cin >> num;
				if(j % 2)
				{
					count += num-48;
				}
			}
		}
	}
	/*for(int i = 0; i < r; i++)
	{
		row = new char[c];
		for(int j = 0; j < c; j++)
		{
			row[j] = 0;
		}
		cin >> row;
		if(cin.eof())
		{
			break;
		}
		for(int k = 0; k < c; k++)
		{
			count += row[k] - 48;
		}
		delete row;
	}*/
	cout << count << endl;
	return 0;
}