Dyson Box(假期集训)

 

 

思路:记录下每行每列的个数,当计算总长度时候,左右是否有方块有方块就-2,只要有重合的地方就-2 



#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<stack>
#include<string>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<cstring>
#include <unordered_set>
//#include<priority_queue>
#include<queue>
#include<set>
#include<stdlib.h>
#define dbug cout<<"hear!"<<endl;
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define endl "\n"
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//priority_queue<int,vector<int>,greater<int> >q;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> PII;
typedef pair<long double,long double> PDD;

 ll  INF = 0x3f3f3f3f;
//const ll LINF=LLONG_MAX;

const ll N = 2e6+ 10;
const ll mod =998244353;
ll t,n,m,x,y,ca;
ll arr[N],brr[N],crr[N];
 //ll book[N];



void fatchuan()
{
  cin>>n;
  map<int,int>left,right;
  ll ans1 =0 ,ans2 = 0;
  rep(i,1,n)
  {
    ans1 += 4, ans2 += 4;
    int x,y;
    cin >> x >> y;
    left[x]++,right[y]++;
    if(left[x]>1)ans1 -= 2;
    if(right[y]>1)ans2 -= 2;
    if(right[y+1]>=right[y])ans2 -= 2;
    if(right[y-1]>=right[y] && y-1 !=0)ans2 -= 2;
    if(left[x-1] >= left[x] && x-1 !=0)ans1 -= 2;
    if(left[x+1] >= left[x])ans1 -= 2;
    cout<<ans1<<' '<<ans2<<endl;
  }
}



int main()
{
    IOS;
    t=1;
    //scanf("%d",&t);
    //cin>>t;
    ca=1;
    while(t--)
    {
      fatchuan(); 
      ca++;
    }    
    return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值