多校第二场

这场赛后把线段树和搜索两题目做了。。。比赛中A还是做不到难过

HDU 4618 Palindrome Sub-Array

相当暴力,各种YY............施教主秒过,赛后我也没做了


HDU 4619 Warm up 2 

一道裸的二分图匹配

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <climits>//形如INT_MAX一类的
#define MAX 1111
#define INF 0x7FFFFFFF
#define REP(i,s,t) for(int i=(s);i<=(t);++i)
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define L(x) x<<1
#define R(x) x<<1|1
# define eps 1e-5
//#pragma comment(linker, "/STACK:36777216") ///传说中的外挂
using namespace std;


int n,m;
int g[MAX][MAX],link[MAX];
bool vis[MAX];

struct node {
    int x,y;
} h[1007],v[1007];

bool judge(int i,int j) {
    if(h[i].x<=v[j].x&&v[j].x<=h[i].x+1) {
        if(v[j].y<=h[i].y&&h[i].y<=v[j].y+1)
            return true;
    }
    return false;
}
bool find(int i) {
    for(int j=1; j<=m; j++)
        if(g[i][j]&&!vis[j]) {
            vis[j]=true;
            if(link[j]==0||find(link[j])) {
                link[j]=i;
                return true;
            }
        }
    return false;
}
int main() {
    while(scanf("%d%d",&n,&m),n|m) {
        int count=0;
        memset(g,0,sizeof(g));
        memset(link,0,sizeof(link));
        for(int i=1; i<=n; i++)
            scanf("%d%d",&h[i].x,&h[i].y);
        for(int i=1; i<=m; i++)
            scanf("%d%d",&v[i].x,&v[i].y);
        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                if(judge(i,j)) {
                    g[i][j]=1;
                }
        for(int i=1; i<=n; i++) {
            memset(vis,0,sizeof(vis));
            if(find(i))
                count++;
        }
        printf("%d\n",n+m-count);
    }
    return 0;
}


HDU 4614 Vases and Flowers

http://blog.csdn.net/watermuch/article/details/9494277


HDU 4620 Fruit Ninja Extreme

http://blog.csdn.net/watermuch/article/details/9637065


你可能感兴趣的:(多校第二场)