2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 A,C,F , H

2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛

A. Banana

Bananas are the favoured food of monkeys.
In the forest, there is a Banana Company that provides bananas from different places.
The company has two lists.
The first list records the types of bananas preferred by different monkeys, and the
second one records the types of bananas from different places.
Now, the supplier wants to know, whether a monkey can accept at least one type of
bananas from a place.
Remenber that, there could be more than one types of bananas from a place, and there
also could be more than one types of bananas of a monkey’s preference.

n 只猴子,每只猴子喜欢吃不同的香蕉,每棵树上有几种香蕉
问,对每只猴子,可以去哪些树上吃香蕉?

直接数组(向量)存,然后STL的去重就可以吧,(感觉自己写的好丑)

/*******************************************************************/
/*******************************************************************/
// author : *****
//     id : *****
//problem : A
//pro  id : 
/*******************************************************************/
/*******************************************************************/
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

#include <time.h>
#include <limits.h>
#include <assert.h>

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <vector>
using namespace std;
#define pb push_back
#define vi vector<int> 
#define pi pair<int,int>
#define LL long long
#define MEM(a) memset(a,0,sizeof(a));
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define lowbit(x) ((x)&-(x))
#define SI(a) ((a).size())

#define MAX 55
#define INF (0x3f3f3f3f)
#define F (1000000007)

int n,m;
std::vector<int> ans[MAX];
std::vector<int> arr[MAX];
std::vector<int> brr[MAX];
// int len[MAX];
int main(int argc, char const *argv[])
{
    // freopen("data.in","r",stdin);
    int T;scanf("%d",&T);
    bool first = true;
    while(T--) {
        if(first) first = false;
            else printf("\n");
        scanf("%d%d",&n,&m);
        For(i,max(n,m)) ans[i].clear(),arr[i].clear(),brr[i].clear();
        Rep(i,n) {
            int a,b;
            scanf("%d%d",&a,&b);
            arr[a].pb(b);
        }
        Rep(i,m) {
            int a,b;
            scanf("%d%d",&a,&b);
            brr[a].pb(b);
        }
        For(i,n) {
            for(int j=0;j<arr[i].size();j++) {
                for(int k = 0;k<brr[arr[i][j]].size();k++) {
                    ans[i].pb(brr[arr[i][j]][k]);
                }
            }   
            sort(ans[i].begin(), ans[i].end());
            vector<int>::iterator end_unique =  unique(ans[i].begin(), ans[i].end()); 
            ans[i].erase(end_unique, ans[i].end());
        }
        For(i,n) {
            for(int j = 0 ; j<ans[i].size();j++) printf("%d %d\n",i,ans[i][j]);
        }
    }
    return 0;
}

C: Coconut

Coconut is Captain Gangplank’s favourite fruit. That is why he needs to drink coconut
juice from b coconuts each day.
On his next trip, he would pass through N citis.
His trip would begin in the 1-st city and end in the N-th city.
The journey from the i-th city to the (i+1)-th city costs D days.
Initially, there is no coconut on his ship. Fortunately, he could get supply of C coconuts
from the i-th city.
Could you tell him, whether he could drink coconut juice every day during the trip no
not?

模拟题 直接模拟就好

/*******************************************************************/
/*******************************************************************/
// author : *****
//     id : *****
//problem : C
//pro  id : 
/*******************************************************************/
/*******************************************************************/
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

#include <time.h>
#include <limits.h>
#include <assert.h>

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <vector>
using namespace std;
#define pb push_back
#define vi vector<int> 
#define pi pair<int,int>
#define LL long long
#define MEM(a) memset(a,0,sizeof(a));
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define lowbit(x) ((x)&-(x))
#define SI(a) ((a).size())

#define MAX 55
#define INF (0x3f3f3f3f)
#define F (1000000007)
int t,n,b; 
int c[1001],d[1001];
int cur;
bool solve()
{
    cur=0;
    for(int i=0;i<n;i++)
    {
        cur+=c[i];
        if(cur>=d[i]*b)
        {
            cur-=d[i]*b;
        }
        else
        return false;
    }
    return true;
}
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&b);

        for(int i=0;i<n;i++)
        scanf("%d",&c[i]);
        for(int i=0;i<n-1;i++)
        scanf("%d",&d[i]);

        if(solve())
        printf("Yes\n");
        else
        printf("No\n");
    }
    return 0;
}

H: Skiing

In this winter holiday, Bob has a plan for skiing at the mountain resort.
This ski resort has M different ski paths and N different flags situated at those turning
points.
The i-th path from the Si-th flag to the T-th flag has length Li.
Each path must follow the principal of reduction of heights and the start point must be
higher than the end point strictly.
An available ski trail would start from a flag, passing through several flags along the
paths, and end at another flag.
Now, you should help Bob find the longest available ski trail in the ski resort.

n 个点 m 条有向路 反向建边 DFS ….蛤….

/*******************************************************************/
/*******************************************************************/
// author : *******
//     id : *******
//problem : H
//pro  id : *******
/*******************************************************************/
/*******************************************************************/
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

#include <time.h>
#include <limits.h>
#include <assert.h>

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <vector>
using namespace std;
#define pb push_back
#define vi vector<int> 
#define pi pair<int,int>
#define LL long long
#define MEM(a) memset(a,0,sizeof(a));
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define lowbit(x) ((x)&-(x))
#define SI(a) ((a).size())

#define MAX 10050
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pil pair<int,LL>
int n,m;
std::vector<pil> G[MAX];
int in[MAX],vis[MAX];
LL len[MAX];
LL dfs(int s) {
    // printf("s = %d\n", s);
    vis[s] = 1;
    for(int i=0;i< G[s].size() ;i++) {
        pi to = G[s][i];
        if(vis[to.first]==0) dfs(to.first);
        len[s] = max(len[s],len[to.first]+to.second);
    }
}
int main(int argc, char const *argv[])
{
    // freopen("data.in","r",stdin);
    int T;scanf("%d",&T);
    while(T--) {
        scanf("%d%d",&n,&m);
        MEM(in);
        MEM(vis);
        MEM(len);
        For(i,n) G[i].clear();
        Rep(i,m) {
            int u,v;LL d;scanf("%d%d%lld",&u,&v,&d);
            G[v].pb(make_pair(u,d));
            in[u]++;
        }
        LL ans = 0;
        For(i,n) {
            if(in[i]==0) {
                // printf("i = %d\n",i);
                if(vis[i]==0) dfs(i);
                ans = max(ans,len[i]);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

F: Islands

hdu 2767 原题??????

引用 HDU2767题解

看着34个AK ,还有什么话要说呢

顺便吐槽一下计蒜客。。。
到现在,题库还没更新

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值