牛客网暑期ACM多校训练营(第二场)I-car 【规律】

I-car

无论是HDU的多校还是牛客的多校,给大家的感觉是。感觉很对,但是不能证明是对的,也不能证明是错的。 大胆猜测就AC,有时候感觉。。。。  有什么办法呢

对于这题,确实已经快想到正确答案了,只是没想到对于边界情况也可以等价删行删列

#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int MOD=1e9+7;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
map<int,int> r,c;
int main(void){
    int n,m;
    sf(n),sf(m);
    for(int i=1;i<=m;i++){
        int x,y;
        sf(x),sf(y);
        r[x]=1,c[y]=1;
    }
    ll ans=2ll*n;
    if(n%2==0){
        printf("%lld\n",ans-(int)r.size()-(int)c.size());
    }
    else{
        ans--;
        ans-=(int)r.size()+(int)c.size();
        int pos=(n+1)/2;
        if(c[pos])  ans++;
        if(r[pos])  ans++;
        if(c[pos]&&r[pos]){ans--;}
        else if(c[pos] || r[pos]){}
        printf("%lld\n",ans);
    }
 
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值