Skip to content

Instantly share code, notes, and snippets.

@OmarJH
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmarJH/82125a4c247454f2175b to your computer and use it in GitHub Desktop.
Save OmarJH/82125a4c247454f2175b to your computer and use it in GitHub Desktop.
Board HakerRank
#include <iostream>
#include <vector>
using namespace std;
int main()
{
char m;
int xs, ys,n1,n2,tx,ty,coun=0;
vector < vector <int> > a;
cin >> xs >> ys;
a.resize(xs);
for (int i = 0; i < xs; i++)
a[i].resize(ys);
cin >> n1;
for (int i = 0; i < n1; i++)
{
cin >> tx;
cin >> m;
cin >> ty;
a[tx][ty] = 1;
}
cin >> n2;
for (int i = 0; i < n2; i++)
{
cin >> tx;
cin >> m;
cin >> ty;
for (int j = 0; j < ys; j++)
a[tx][j] = 0;
for (int j = 0; j < xs; j++)
a[j][ty] = 0;
}
for (int i = 0; i < xs; i++)
{
for (int j = 0; j < ys; j++)
{
if (a[i][j] == 1)
coun++;
}
}
cout << coun << endl;
//cin >> coun;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment