2017icpc 乌鲁木齐网络赛

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.

Input Format

The first line contains an integer TT, indicating that there are TT test cases.

For each test case, the first line contains two integers NN and MM, representing the length of the first and the second lists respectively.

In the each line of following NN lines, two positive integers i, ji,j indicate that the ii-th monkey favours the jj-th type of banana.

In the each line of following MM lines, two positive integers j, kj,k indicate that the jj-th type of banana could be find in the kk-th place.

All integers of the input are less than or equal to 5050.

Output Format

For each test case, output all the pairs x, yx,y that the xx-the monkey can accept at least one type of bananas from the yy-th place.

These pairs should be outputted as ascending order. That is say that a pair of x, yx,y which owns a smaller xx should be output first.

If two pairs own the same xx, output the one who has a smaller yy first.

And there should be an empty line after each test case.

样例输入


6 4 
1 1 
1 2 
2 1 
2 3 
3 3 
4 1 
1 1 
1 3 
2 2 
3 3 
样例输出

1 1 
1 2 
1 3 
2 1 
2 3 
3 3 
4 1 
4 3



签到,写两个map记录每个产地有哪几种水果,每个猴子喜欢哪种水果,双重for一下,第三重用map迭代器迭代下各产地的各个水果种类是否能有对应猴子喜欢就行。

 1 #include<bits/stdc++.h>
 2 #define clr(x) memset(x,0,sizeof(x))
 3 #define clr_1(x) memset(x,-1,sizeof(x))
 4 #define LL long long
 5 #define mod 1000000007
 6 using namespace std;
 7 map<int,bool>::iterator it;
 8 int main()
 9 {
10     int n,m,T,u,v;
11     scanf("%d",&T);
12     while(T--)
13     {
14         scanf("%d%d",&n,&m);
15         map<int,bool> a[60],b[60];
16         for(int i=1;i<=n;i++)
17         {
18             scanf("%d%d",&u,&v);
19             a[u][v]=1;
20         }
21         for(int j=1;j<=m;j++)
22         {
23             scanf("%d%d",&u,&v);
24             b[v][u]=1;
25         }
26         for(int i=1;i<=50;i++)
27         {
28             for(int j=1;j<=50;j++)
29             {
30                 for(it=b[j].begin();it!=b[j].end();it++)
31                 {
32                     if(a[i].find(it->first)!=a[i].end())
33                     {
34                         printf("%d %d\n",i,j);
35                         break;
36                     }
37                 }
38             }
39         }
40         printf("\n");
41     }
42     return 0;
43 }

C.Coconut

Coconut is Captain Gangplank’s favourite fruit. That is why he needs to drink coconut juice from bb coconuts each day.

On his next trip, he would pass through NN citis.

His trip would begin in the 11-st city and end in the NN-th city.

The journey from the ii-th city to the (i+1)(i+1)-th city costs D_iD 
?i 
?? days.

Initially, there is no coconut on his ship. Fortunately, he could get supply of C_iC 
?i 
?? coconuts from the ii-th city.

Could you tell him, whether he could drink coconut juice every day during the trip no not?

Input Format

The first line contains an integer TT, indicating that there are TT test cases.

For each test case the first line contains two integers NN and bb as described above.

The second line contains NN integers C_1, C_2, \cdots, C_NC 
?1 
?? ,C 
?2 
?? ,?,C 
?N 
?? .

The third line contains N-1N?1 integers D_1, D_2, \cdots, D_{N-1}D 
?1 
?? ,D 
?2 
?? ,?,D 
?N?1 
?? .

All integers in the input are less than 10001000.

Output Format

For each case, output Yes if Captain Gangplank could drink coconut juice every day, and otherwise output No.

样例输入


4 1 
3 2 1 4 
1 2 3 
4 2 
2 4 6 8 
3 2 1 
样例输出

Yes 
No



水题,for一遍就好了。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3
 4 int sum[1005];
 5
 6 int main() {
 7     int n, b;
 8     int  t;
 9     scanf("%d", &t);
10     while(t --) {
11         scanf("%d%d", &n, &b);
12         memset(sum, 0, sizeof(sum));
13         for(int i = 1; i <= n; ++ i) {
14             int x;
15             scanf("%d", &x);
16             sum[i] = sum[i-1] + x;
17         }
18         int a = 0;
19         bool ok = true;
20         for(int i = 2; i <= n; ++ i) {
21             int x;
22             scanf("%d", &x);
23             a += x*b;
24             if(sum[i-1] < a) {
25                 ok = false;
26             }
27         }
28         if(ok) {
29             puts("Yes");
30         }
31         else {
32             puts("No");
33         }
34     }
35     return 0;
36 }

E. Half-consecutive Numbers



emmm就是打个表的事情嘛~,如果嫌麻烦直接上eios233333。

 1 #include<bits/stdc++.h>
 2 #define clr(x) memset(x,0,sizeof(x))
 3 #define clr_1(x) memset(x,-1,sizeof(x))
 4 #define LL long long
 5 #define mod 1000000007
 6 using namespace std;
 7 LL a[23]={    0, 1, 8, 49, 288, 1681, 9800, 57121, 332928, 1940449, 11309768, 65918161, 384199200, 2239277041, 13051463048, 76069501249, 443365544448, 2584123765441, 15061377048200, 87784138523761, 511643454094368, 2982076586042449, 17380816062160328};
 8 int main()
 9 {
10     int T;
11     LL n;
12     scanf("%d",&T);
13     for(int kase=1;kase<=T;kase++)
14     {
15         scanf("%lld",&n);
16         for(int i=0;i<23;i++)
17         if(a[i]>=n)
18         {
19             printf("Case #%d: %lld\n",kase,a[i]);
20             break;
21         }
22     }
23     return 0;
24 }

时间: 2024-10-08 19:08:51

2017icpc 乌鲁木齐网络赛的相关文章

2017icpc乌鲁木齐网络赛Colored Graph (构造)

题目 https://nanti.jisuanke.com/t/16958 题意 给定一个n(n<=500)个点的无向图,给每条边黑白染色,输出同色三角形最少的个数和对应的方案 分析 首先考虑给定一个染色完毕的无向图,如何求同色三角形的个数 同色三角形的个数=总的个数-异色三角形的个数 而一个异色三角形对应两个异色角,所以我们可以通过算异色角的个数来计算异色三角形的个数 而异色角是有一个固定的点i引出去的n-1条边所决定的 设某个点i有$x_i$条1边,有$n-1-x_i$条2边 可以发现异色角

【后缀数组】【RMQ】HDU 6194 - string string string (2017ICPC沈阳网络赛)

string string string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Uncle Mao is a wonderful ACMER. One day he met an easy problem, but Uncle Mao was so lazy that he left the problem to you. I

2017ICPC沈阳网络赛 HDU 6025 -- card card card(最大子段和)

card card card Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1230    Accepted Submission(s): 549 Problem Description As a fan of Doudizhu, WYJ likes collecting playing cards very much. One day

2017乌鲁木齐网络赛 J题 Our Journey of Dalian Ends ( 最小费用最大流 )

题目链接 题意 : 给出一副图,大连是起点,终点是西安,要求你求出从起点到终点且经过中转点上海的最小花费是多少? 分析 : 最短路是最小费用最大流的一个特例,所以有些包含中转限制或者经过点次数有限制的最短路问题都可以考虑使用最小费用最大流来建图解决. 首先对于每个点都只能经过一次这个限制,在网络流中是比较常见的一个限制,只要将所有的点由一拆二且两点间连容量为 1 且花费为 0 的边. 这题的建图很巧妙,是将中转点作为汇点,提示到了这里不如停下来想想如何建图? 然后抽象出一个超级源点,然后将起点和

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

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 seco

hdu6153 A Secret CCPC网络赛 51nod 1277 KMP

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意: 给出两个字符串S1,S2,求S2的所有后缀在S1中出现的次数与其长度的乘积之和. 思路: CCPC网络赛题解: https://post.icpc-camp.org/d/714-ccpc-2017 http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1277   是一样的 将s1,s2翻转,转化为求前缀在s1中出

2015长春网络赛总结

早上七点多就(冻)醒来了,训练了一个暑假,acm生涯的第一场网络赛,很激动. 九点开打,我拔不出网线,用的机房电脑,装的cb有问题,不能编译,只好用dev.男神电脑插上网线没有网,习惯了linux可能不习惯吧.这提醒我们以后一定要早点去把环境调好. 第三分钟,G题有人A了.我跟560开始看题,男神还在弄电脑.题意是给你n个数(n<1000),然后q(q<1000)次询问,要求你输出[l,r]区间的最大值.数据很小,我说暴力,然后560说线段树,然后模板13分钟1Y.然后560开始搞J,一个貌似

2015长春、沈阳网络赛总结

我所说的总结并不是谈什么题目解法之类的东西 这些东西网上有很多题解 说说这两场网赛吧! 这两场我的状态还行,只是xiaodong还没有找到状态,长春赛lucas+中国剩余定理他硬是打了一整场,还是没打出来,版题没打出来确实不该 wzb状态一般,不过看题的能力依然那么厉害 长春赛中,很遗憾的只出了5道题,按当时过题数目,应该是7道德,可是小东的lucas那题没打出来,而我打得后缀数组那题,当顺时针的时候不用看是否是下标最前面的,但是反过来就需要看了,当时想当然的认为不用,交了4发,一直wa到比赛结

树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

1 // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree 2 // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以走多次,问从每个点出发的最大获益 3 // 思路: 4 // dp[i]: 从i点出发回到i点的最大值 5 // d[i][0] 从i点出发不回来的最大值 6 // d[i][1] 从i点出发取最大值的下一个点 7 // d[i][2] 从i点出发取次大值 8 // dfs1处理出这四个 9