这次没去考试:就考试结尾场外交题了一道题。B题是补得。

因为和女朋友和好啦 开心 我以后要好好对她 不可以惹她生气了。好好学习。加油!

A

The ACM International Collegiate Programming Contest has been held in Vietnam for more than 1010 years. The contest is a great chance for the students to meet new friends, broaden their knowledge and of course, win prizes.

Every years, universities can send one or multiple teams to the contest and all universities hope to win prizes. The organizers want to define a rule to award the excellent contestants.

The contest director decided to follow the World Finals policy by having 44 first prizes, 44 second prizes and 44 third prizes. 1212 winners out of more than a hundred teams is also a good proportion to recognize the best students.

Since universities can send multiple teams, we don’t want one university to swept all the awards. Thus, only the top team from a university can be awarded. It seems harsh for the second best team from one university but do not worry, they will still receive relevant certificates.

The table below is the result of top 1010 of Nha Trang Regional Contest 2016. The 44 -th (team WINDOWS) and 88 -th place (team UBUNTU) did not receive prizes because they were not the top team from University of Engineering and Technology - VNU. Team Metis and team BK.DeepMind are in the same situation.

Place

Institution

Team

Prize

11

Seoul National University

ACGTeam

First Prize

22

University of Engineering and Technology - VNU

LINUX

First Prize

33

Shanghai Jiao Tong University

Mjolnir

First Prize

44

University of Engineering and Technology - VNU

WINDOWS

 

55

National Taiwan University

PECaveros

First Prize

66

Hanoi University of Science and Technology

BK.Juniors

Second Prize

77

Ho Chi Minh City University of Science

HCMUS-Serendipity

Second Prize

88

University of Engineering and Technology - VNU

UBUNTU

 

99

Shanghai Jiao Tong University

Metis

 

1010

Hanoi University of Science and Technology

BK.DeepMind

 

Given the final scoreboard of the contest, your task is to determine which 1212 teams should be awarded prizes.

Input

  • The input starts with the number of teams NN (12≤N≤20012≤N≤200 ).

  • The ii -th line of the next NN lines contains information about the team that ranks ii : the university name and the team name separated by a single space. Both names consists of digits, lowercase and uppercase English alphabet letters only. Both names does not exceed 2020 letters in length.

  • It is guaranteed that there are at least 1212 different universities.

Output

The output should contain 1212 lines describing 1212 winners. In each line, you should print the university name and the team name separated by a single space. The winners should be listed in the same order as the input.

Sample Input 1 Sample Output 1
30
Seoul ACGTeam
VNU LINUX
SJTU Mjolnir
VNU WINDOWS
NTU PECaveros
HUST BKJuniors
HCMUS HCMUSSerendipity
VNU UBUNTU
SJTU Metis
HUST BKDeepMind
HUST BKTornado
HCMUS HCMUSLattis
NUS Tourism
VNU DOS
HCMUS HCMUSTheCows
VNU ANDROID
HCMUS HCMUSPacman
HCMUS HCMUSGeomecry
UIndonesia DioramaBintang
VNU SOLARIS
UIndonesia UIChan
FPT ACceptable
HUST BKIT
PTIT Miners
PSA PSA
DaNangUT BDTTNeverGiveUp
VNU UNIXBSD
CanTho CTUA2LTT
Soongsil Team10deung
Soongsil BezzerBeater
Seoul ACGTeam
VNU LINUX
SJTU Mjolnir
NTU PECaveros
HUST BKJuniors
HCMUS HCMUSSerendipity
NUS Tourism
UIndonesia DioramaBintang
FPT ACceptable
PTIT Miners
PSA PSA
DaNangUT BDTTNeverGiveUp

A题很简单,一道HASH题即可。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>#define MOD 10000000
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
ULL base=233;
long long quickpow(long long n, long long base) {long long res = 1;while(n) {if(n & 1) {res = res * base % MOD;}n >>= 1;base = base * base % MOD;}return res;
}//快速幂
ULL HASH(char s[])
{int l=strlen(s);ULL ans=0;for(int i=0;i<l;i++){ans=ans*base+(ULL)s[i];}return ans;
}
set<ULL>hash0;//手动哈希 char B[30],C[30];int main()
{ULL hash1; int N;cin>>N;int SIZE=0;while(N--){int i=0;cin>>B>>C;hash1=HASH(B);hash0.insert(hash1);if(hash0.size()>SIZE){SIZE=hash0.size();cout<<B<<" "<<C<<endl;}if(SIZE==12)break;}}

B

The tunnels of Cu Chi are an immense network of underground tunnels connecting rooms located in the Cu Chi District of Ho Chi Minh City. The Cu Chi tunnels were the location of several military campaigns in the 1960s. Nowadays, it is a popular tourist destination.

There are documents from trusted sources about a private network of tunnels in this area used by a secret forces unit but it has not been discovered. According to the documents, this private network has NN rooms (numbered from 11 to NN ) connected by N−1N−1 bidirectional tunnels. Room 11 is the entry point from the ground surface to this underground network. From room 11 , you can follow the tunnels to go to any of the rooms. The rooms are numbered in such a way that, if you follow the shortest path from room 11 to any room XX , the sequence of visited rooms’ indices will be increasing. The image below shows a valid map of this network.

The network below is invalid, since the path from 11 to 44 is 11 - 33 - 22 - 44 , which is not increasing:

There is also an old article from an unknown source mentioning about DiDi which is the number of rooms directly connected to room ii .

Given an array DD of size NN , your task is to verify if it is possible to have such a network.

Input

  • The first line contains an integer NN - the number of rooms in the network (2≤N≤1000)(2≤N≤1000) .

  • The second line consists of NN integers DiDi - the number of rooms that are directly connected to room ii (1≤Di≤N−1)(1≤Di≤N−1) .

Output

Print YES/NO if it is possible/impossible to have such a network, respectively.

Sample Input 1 Sample Output 1
8
3 2 2 1 1 3 1 1
YES
Sample Input 2 Sample Output 2
4
3 3 3 3
NO

贪心题:主要不断加入尽可能小的且能加入的点(度数满足要求),没加入一次,两个点都减少1个度数,并把新的点加入图中(这里用set存图),加入的就map=1,以免下次使用的时候又把这个点加上了:比如第二层是2、3、4,2往下又加上了5、6,但是3往下也可以加5、6,但已经被加上了就不能加了。

最后判断度数是否都为0,中间有些情况可以提前结束判断。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>#define MOD 10000000using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
ULL base=233;
long long quickpow(long long n, long long base) {long long res = 1;while(n) {if(n & 1) {res = res * base % MOD;}n >>= 1;base = base * base % MOD;}return res;
}//快速幂
ULL HASH(char s[])
{int l=strlen(s);ULL ans=0;for(int i=0;i<l;i++){ans=ans*base+(ULL)s[i];}return ans;
}
set<ULL>hash0;//手动哈希
set<ULL>::iterator it;//STL迭代器 int A[1010];
set< int >set0;
map<int,int>map0;
int main()
{int N;cin>>N;for(int i=1;i<=N;i++){cin>>A[i];map0[i]=0;}set0.insert(1);while(!set0.empty()){int k=*set0.begin();set0.erase(k);if(A[k]>0)for(int i=k+1;i<=N;i++){if(A[i]>=1&&map0[i]==0){A[k]--;A[i]--;set0.insert(i);map0[i]=1;}if(A[k]==0)break;}if(A[k]>0)break;}for(int i=1;i<=N;i++){if(A[i]!=0){cout<<"NO"<<endl;return 0;}}cout<<"YES"<<endl;
}

E

Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.

There is a sequence a that consists of n integers a1, a2, ..., an. Let's denote f(l, r, x) the number of indices k such that: l ≤ k ≤ r and ak = x. His task is to calculate the number of pairs of indicies i, j (1 ≤ i < j ≤ n) such that f(1, i, ai) > f(j, n, aj).

Help Pashmak with the test.

Input

The first line of the input contains an integer n (1 ≤ n ≤ 106). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print a single integer — the answer to the problem.

Examples

Input

7
1 2 1 1 2 2 1

Output

8

Input

3
1 1 1

Output

1

Input

5
1 2 3 4 5

Output

0

E题是一道对我来说的一个总结性很强的题:有单独讲:https://blog.csdn.net/mxYlulu/article/details/81137457

 

UESTC 2018 Summer Training #4 Div.2相关推荐

  1. UESTC 2014 Summer Training #7 Div.2

    DAY7一开始状态还行,最高纪录rank7,然后没力气了,一直跌到rank24,问题还是很多呐.昨天总结的问题依然很大. Problem A UVA 12377 就一开始还是慌了,没审清楚题意就去WA ...

  2. 2018 Multi-University Training Contest 3 Problem F. Grab The Tree 【YY+BFS】

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6324 Problem F. Grab The Tree Time Limit: 2000/1000 MS ...

  3. 2018 Multi-University Training Contest 4 Problem E. Matrix from Arrays 【打表+二维前缀和】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6336 Problem E. Matrix from Arrays Time Limit: 4000/20 ...

  4. 2020 BUPT Winter Training #1 Div.1

    2020 BUPT Winter Training #1 Div.1 这些题真的很不错 读完题一道都不会 补完每一道都骂自己sb 文章目录 [A - Cover it!](https://vjudge ...

  5. Photoshop CC 2018 Essential Training: Design Photoshop CC 2018基本培训:设计 Lynda课程中文字幕

    Photoshop CC 2018 Essential Training: Design 中文字幕 Photoshop CC 2018基本培训:设计 中文字幕Photoshop CC 2018 Ess ...

  6. ZBrush 2018 Essential Training ZBrush 2018基本培训 Lynda课程中文字幕

    ZBrush 2018 Essential Training 中文字幕 ZBrush 2018基本培训 中文字幕ZBrush 2018 Essential Training ZBrush将3D建模,纹 ...

  7. Substance Painter 2018 Essential Training Substance Painter 2018基础教程 Lynda课程中文字幕

    Substance Painter 2018 Essential Training 中文字幕 Substance Painter 2018基础教程 中文字幕Substance Painter 2018 ...

  8. Photoshop CC 2018 Essential Training: Photography Photoshop CC 2018基础培训:摄影 Lynda课程中文字幕

    Photoshop CC 2018 Essential Training: Photography 中文字幕 Photoshop CC 2018基础培训:摄影 中文字幕Photoshop CC 201 ...

  9. Photoshop CC 2018 Essential Training: The Basics Photoshop CC 2018基本培训:基础 Lynda课程中文字幕

    Photoshop CC 2018 Essential Training: The Basics 中文字幕 Photoshop CC 2018基本培训:基础 中文字幕Photoshop CC 2018 ...

最新文章

  1. 更简单的调试Release版本Optimize code的.NET程序集
  2. 几种常见的JVM调优场景(建议收藏)
  3. 通过 python-xmp-toolkit 读取图片xmlp信息
  4. jpeg6 安装问题!
  5. Redis:安装、配置、操作和简单代码实例(C语言Client端)[转]
  6. 网络工程师如何避免走弯路(二)
  7. char *转为pansichar
  8. 清华大学电机学答案_电机学清华大学答案
  9. SQL语句的优化建议
  10. 64位计算机安装xp,Windows XP(64位)如何安装语言包
  11. ubuntu linux多声卡设置默认声卡shell指令
  12. 银行专业术语解释说明 超级详细
  13. 最强推荐:阿里P7级别面试经验总结,进阶学习资料!
  14. 微生物组-扩增子16S分析和可视化(2023.2)
  15. 注塑模具设计的技术知识汇总
  16. postman tests获取cookie
  17. 特殊符号html怎么打出来的,特殊符号怎么打出来
  18. 图书馆管理系统Python+MySQL+tkinter图形化界面+管理员登录+学生登录(注释详细)
  19. C++, 多态应用举例之Word
  20. SRM- Golink体验报告

热门文章

  1. HTMLbutton 标签和input type=button的区别
  2. 免杀方法(一)mimikazta
  3. iOS10集成siri
  4. 方程的近似解c语言程序,C语言实现二分法(方程近似解)
  5. 场景化AI数据推动智慧家居发展
  6. 米家APP又崩了,智能家居还可靠吗?
  7. 码农的跑步里程碑5000公里
  8. 输出图案-平行四边形
  9. php 字符串中英文混合截取,PHP截取中英混合的字符串
  10. 【限流算法】java实现redis分布式时间窗口计数器算法