码迷,mamicode.com
首页 > 其他好文 > 详细

【洛谷八连测R5】whzzt-Conscience

时间:2017-10-28 22:35:50      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:com   col   string   --   etc   space   ace   ems   img   

 

题目描述

题目难度不一定按照题目顺序递增

技术分享

输入输出格式

 技术分享

说明

技术分享

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+5;
inline void read(int &x){
    x=0; char ch=getchar();
    while(ch<0||ch>9) ch=getchar();
    while(ch>=0&&ch<=9){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
}
int T,n,m,q,ans;
bool c1[maxn],c2[maxn];
struct node{
    int x,y;
    inline bool operator < (const node &j) const {
        return x==j.x? y<j.y:x<j.x;
    }
}e[maxn];
int main(){
    read(T);
    while(T--){
        read(n);read(m);read(q); ans=0;
        for(int i=1;i<=q;++i)
            read(e[i].x),read(e[i].y);
        sort(e+1,e+q+1);
        memset(c1,0,sizeof(c1));
        memset(c2,0,sizeof(c2));
        for(int i=1;i<=q;++i){
            if(c1[e[i].x]||c2[e[i].y]) continue;
            ans++; c1[e[i].x]=c2[e[i].y]=1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

【洛谷八连测R5】whzzt-Conscience

标签:com   col   string   --   etc   space   ace   ems   img   

原文地址:http://www.cnblogs.com/huihao/p/7748341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!