首页 > 其他分享 >abc370D Cross Explosion

abc370D Cross Explosion

时间:2024-09-14 17:04:12浏览次数:1  
标签:set Explosion int abc370D Cross erase ans

一开始并查集写的,ga掉。set应用一道非常好的题目。
```
#include <bits/stdc++.h>
#include <set>
#define sii set<int>::iterator
using namespace std;
int h,w,q,ans;
set<int> s1[400007],s2[400007];
void del(int x,int y){
    //printf(" %d %d\n",x,y);
    s1[x].erase(y);
    s2[y].erase(x);
    ans++;
}
signed main(){
    // cout<<"yyy"<<endl;
    scanf("%d%d%d",&h,&w,&q);
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
                // cout<<"xxx"<<endl;
                s1[i].insert(j);
                s2[j].insert(i);
            }
    }
    for(int i=1,x,y;i<=q;i++){
        scanf("%d%d",&x,&y);
        if(*s1[x].lower_bound(y)==y) del(x,y);
        else{
            sii p=s1[x].lower_bound(y);
            if(p!=s1[x].begin()){
                p--;
                del(x,*p);
                //p++;
            }
            p=s1[x].lower_bound(y);
            if(p!=s1[x].end()){
                del(x,*p);
            }
            sii q=s2[y].lower_bound(x);
            if(q!=s2[y].begin()){
                q--;
                del(*q,y);
                //q++;
            }
            q=s2[y].lower_bound(x);
            if(q!=s2[y].end()){
                del(*q,y);
            }
        }
    }
    printf("%d\n",h*w-ans);
    return 0;
}
```

 

标签:set,Explosion,int,abc370D,Cross,erase,ans
From: https://www.cnblogs.com/caterpillor/p/18414352

相关文章

  • cross-plateform 跨平台应用程序-10-naitvescript 介绍
    跨平台系列cross-plateform跨平台应用程序-01-概览cross-plateform跨平台应用程序-02-有哪些主流技术栈?cross-plateform跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?cross-plateform跨平台应用程序-04-ReactNative介绍cross-plateform跨平台应用程序-05-Flut......
  • cross-plateform 跨平台应用程序-09-phonegap/Apache Cordova 介绍
    跨平台系列cross-plateform跨平台应用程序-01-概览cross-plateform跨平台应用程序-02-有哪些主流技术栈?cross-plateform跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?cross-plateform跨平台应用程序-04-ReactNative介绍cross-plateform跨平台应用程序-05-Flut......
  • cross-plateform 跨平台应用程序-05-Flutter 介绍
    跨平台系列cross-plateform跨平台应用程序-01-概览cross-plateform跨平台应用程序-02-有哪些主流技术栈?cross-plateform跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?cross-plateform跨平台应用程序-04-ReactNative介绍cross-plateform跨平台应用程序-05-Flut......
  • cross-plateform 跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?
    跨平台系列cross-plateform跨平台应用程序-01-概览cross-plateform跨平台应用程序-02-有哪些主流技术栈?cross-plateform跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?cross-plateform跨平台应用程序-04-ReactNative介绍cross-plateform跨平台应用程序-05-Flut......
  • cross-plateform 跨平台应用程序-01-概览
    跨平台系列cross-plateform跨平台应用程序-01-概览cross-plateform跨平台应用程序-02-有哪些主流技术栈?cross-plateform跨平台应用程序-03-如果只选择一个框架,应该选择哪一个?cross-plateform跨平台应用程序-04-ReactNative介绍cross-plateform跨平台应用程序-05-Flut......
  • (多模态)MedM2G: Unifying Medical Multi-Modal Generation via CrossGuided Diffusion
    1.摘要医学生成模型以其高质量的样本生成能力而闻名,加速了医学应用的快速增长。然而,目前的研究主要集中在针对不同医疗任务的单独医学生成模型上,受限于医学多模态知识的不足,制约了医学的综合诊断。在本文中,我们提出MedM2G,即医学多模态生成框架,其关键创新是在统一模型内对齐......
  • WPF communicate across different modules via event
    //Runtimeproject,cclasslibraryusingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Linq.Expressions;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Input;namespaceRuntime{publicclassDelCmd:......
  • 【机器学习】8. 逻辑斯蒂回归 Logistic function(sigmoid),cross-entropy error,Log-l
    Logisticfunction线性分类器Logisticfunction(sigmoid)极大似然估计Log-likelihoodloss线性分类器Logisticregression是一个线性分类器。如图,1为蓝色,0为红色。这条直线叫做直线边界Logisticfunction(sigmoid)......
  • DCN V2 Improved Deep & Cross Network and Practical Lessons for Web-scale Learnin
    目录概DCN-v2WangR.,ShivannaR.,ChengD.Z.,JainS.,LinD.,HongL.andChiE.D.DCNV2:Improveddeep&crossnetworkandpracticallessonsforweb-scalelearningtoranksystems,2020.概DCN的升级版.DCN-v2DCN-v2的cross/deep的结合方式上有上......
  • 翻译_Clock Domain Crossing Design
    翻译_ClockDomainCrossingDesign原文标题及连接:ClockDomainCrossing(CDC)Design&VerificationTechniquesUsingSystemVerilog.作者:CliffordE.CummingsSunburstDesign,[email protected]摘要在多时钟设计中,需要在时钟域交叉(ClockDomainC......