Codeforces Cells Not Under Attack
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#define cf %I64d
using namespace std;
#define sf scanf
#define pf printf
typedef long long LL;
typedef map<LL,bool>mpll;
int main()
{
LL n,m;
mpll ro, col;
while(~sf("%I64d %I64d", &n, &m))
{
ro.clear();
col.clear();
LL i , Row=0, Column=0;
for(i=0; i<m; i++)
{
LL x,y;
sf("%I64d %I64d", &x, &y);
if(!ro[x])
{
Row++;
ro[x]=true;
}
if(!col[y])
{
Column++;
col[y] = true;
}
//cout << Row << " " << Column << "\n";
LL ans = (n - Row) * (n - Column);
pf("%I64d\n", ans);
}
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#define cf %I64d
using namespace std;
#define sf scanf
#define pf printf
typedef long long LL;
typedef map<LL,bool>mpll;
int main()
{
LL n,m;
mpll ro, col;
while(~sf("%I64d %I64d", &n, &m))
{
ro.clear();
col.clear();
LL i , Row=0, Column=0;
for(i=0; i<m; i++)
{
LL x,y;
sf("%I64d %I64d", &x, &y);
if(!ro[x])
{
Row++;
ro[x]=true;
}
if(!col[y])
{
Column++;
col[y] = true;
}
//cout << Row << " " << Column << "\n";
LL ans = (n - Row) * (n - Column);
pf("%I64d\n", ans);
}
}
return 0;
}
Comments
Post a Comment