2021.7.27--Benelux Algorithm Programming Contest 2020 补提
I Jigsaw
题目内容:

链接:https://ac.nowcoder.com/acm/contest/18454/I
来源:牛客网 You have found an old jigsaw puzzle in the attic of your house, left behind by the previous occupants. Because you like puzzles, you decide to put this one together. But before you start, you want to know whether this puzzle was left behind for a reason. Maybe it is incomplete? Maybe the box contains pieces from multiple puzzles?
If it looks like a complete puzzle, you also need to know how big your work surface needs to be. Nothing worse than having to start a jigsaw over because you started on a small table. The box does not tell you the dimensions w × h of the puzzle, but you can quickly count the three types of pieces in the box:
• Corner pieces, which touch two of the edges of the puzzle.
• Edge pieces, which touch one of the edges of the puzzle.
• Center pieces, which touch none of the edges of the puzzle.
Do these pieces add up to a complete jigsaw puzzle? If so, what was the original size of the jigsaw puzzle?
输入描述: The input consists of:
• One line containing three integers c, e, and m (0 ≤ c,e,m ≤ 10 9 ), the number of corner pieces, edge pieces, and center pieces respectively. 输出描述: If there exist numbers w and h satisfying w ≥ h ≥ 2 such that the original size of the jigsaw puzzle could have been w×h, then output a single line containing w and h. Otherwise, output “impossible”.
If there are multiple valid solutions, you may output any one of them. 示例1
输入
复制 4 8 4 输出
复制 4 4 示例2
输入
复制 4 10 14 输出
复制 impossible 示例3
输入
复制 4 12 6 输出
复制 impossible 示例4
输入
复制 4 2048 195063 输出
复制 773 255
题意:有一组拼图,分别给出角块c、边缘块e、中心块m的数量,问能否构成一个完整的拼图。若能则输出该拼图的w和h(w>=h>=2),不能则输出“impossible”
思路:题目中w和h>=2,所以角块数至少为4,还可以根据拼图经验可得出方程:w*h==c+e+m; (w-2+h-2)*2==e; (w-2)*(h-2)==m;
所以可据此得到代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int c,e,m;
cin>>c>>e>>m;
if(c>=4){
if(e==0&&m==0){
cout<<2<<" "<<2<<endl;
return 0;
}
else if(e!=0&&m==0&&e%2==0)
{
cout<<e/2+2<<" "<<2<<endl;
return 0;
}
else{
int w,h;
int t=c+e+m;
for(w=2;w*w<=c+e+m;w++)
{
if(t%w==0)
{
h=t/w;
if((w-2+h-2)*2==e&&(w-2)*(h-2)==m)
{
if(w<h)swap(w,h);
cout<<w<<" "<<h<<endl;
return 0;
}
}
}
} }
cout<<"impossible"<<endl;
}
题目内容:

链接:https://ac.nowcoder.com/acm/contest/18454/C
来源:牛客网 You are organizing a programming competition in which the rank of a team is fifirst determined by how many problems they have solved. In case of a tie, the team with the lowest time penalty is ranked above the other. However, contrary to the BAPC, the time penalty is equal to t if the latest accepted submission was submitted in the tth minute, or 0 if no problem was solved.
For example, if team A solved their fifirst problem in the 5th minute, their second problem in the 10th minute and their third problem in the 60th minute, then their time penalty is 60. If team B also solved three problems, in the 30th, 40th and 50th minute, their time penalty is 50 and they would rank above team A.
The contest has fifinished and you would like to enter the fifinal standings. However, due to a corrupted fifile you have lost part of the scoreboard. In particular, the column indicating how many problems each team has solved is gone. You do still have the time penalties of all the teams and know that they are in the right order. You also remember how many problems the contest had. You wonder whether, given this information, it is possible to uniquely reconstruct the number of problems that each team has solved. 输入描述: The input consists of:
•One line containing two integers: n (1 ≤ n ≤ 104), the number of teams participating,and p (1 ≤ p ≤ 104), the number of contest problems.
•n lines with on line i the time score tiin minutes (0 ≤ ti ≤ 106) of the team that is ranked in the ith place.
A positive time score of t indicates that a team has submitted their last accepted submission in the tth minute. A time score of 0 indicates that a team hasn’t solved any problem.
The input always originates from a valid scoreboard. 输出描述: If it is possible to uniquely reconstruct the scores of all the teams, output n lines containing the number of problems that the ith team has solved on the ith line. Otherwise, output “ambiguous”. 示例1
输入
复制 9 3
140
75
101
120
30
70
200
0
0 输出
复制 3
2
2
2
1
1
1
0
0 示例2
输入
复制 6 3
100
40
40
50
0
0 输出
复制 ambiguous
题意:你正在组织一场编程比赛,其中一个团队的排名首先取决于他们解决了多少问题。
在平局的情况下,罚时最少的球队排在另一队之上。但是,与 BAPC 相反,如果最新接受的提交是在第 t 分钟提交的,则时间惩罚等于 t,如果没有解决问题,则时间惩罚等于 0。
比赛已结束,您想进入决赛排名。但是,由于文件损坏,您丢失了记分板的一部分。特别是,显示每个团队解决了多少问题的列不见了。你仍然有所有球队的时间处罚,并且知道他们的顺序是正确的。你还记得比赛有多少问题。您想知道,根据这些信息,是否可以唯一地重建每个团队已解决的问题数量。
输入描述: 一行包含两个整数:n (1 ≤ n ≤ 104),参赛队数,p (1 ≤ p ≤ 104),比赛题数。 • n 行,第i 行是排在第i 位的球队的时间得分tiin 分钟(0 ≤ ti ≤ 106)。 t 的正时间分数表示团队在第 t 分钟提交了他们最后一次接受的提交。时间分数为 0 表示团队没有解决任何问题。 输入始终来自有效的记分板。
输出描述: 如果可以唯一地重建所有团队的分数,则输出 n 行,其中包含第 i 行上第 i 个团队已解决的问题数。否则,输出“ambiguous”。
思路: 可以确定分数时: 1.从榜首到最后一名均为0 2. 不为0时,过题数从m到1或从m到0
不可以确定分数时: 1. 最后一名罚时为0但过题数不为0 2.最后一名罚时不为0,但过题数不为1
代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,p;
cin>>n>>p;
int s[10010],v[10010],k=0;
for(int i=0;i<n;i++)
{
cin>>s[i];
if(s[i]!=0)k=1;
}
if(k==0)
{
while(n--){
cout<<0<<endl;
} }
else{
v[0]=p;
for(int i=1;i<n;i++)
{
if(s[i]<s[i-1])v[i]=--p;
else v[i]=p;
}
if((v[n-1]!=1&&s[n-1]!=0)||(v[n-1]!=0&&s[n-1]==0))//此处不要弄错
cout<<"ambiguous"<<endl;
else {
for(int i=0;i<n;i++)cout<<v[i]<<endl;
}
}
}
2021.7.27--Benelux Algorithm Programming Contest 2020 补提的更多相关文章
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- 2020.3.14--训练联盟周赛 Preliminaries for Benelux Algorithm Programming Contest 2019
1.A题 题意:给定第一行的值表示m列的最大值,第m行的值表示n行的最大值,问是否会行列冲突 思路:挺简单的,不过我在一开始理解题意上用了些时间,按我的理解是输入两组数组,找出每组最大数,若相等则输出 ...
- 2020.3.21--ICPC训练联盟周赛Benelux Algorithm Programming Contest 2019
A Appeal to the Audience 要想使得总和最大,就要使最大值被计算的次数最多.要想某个数被计算的多,就要使得它经过尽量多的节点.于是我们的目标就是找到 k 条从长到短的链,这些链互 ...
- 2014 Benelux Algorithm Programming Contest (BAPC 14)E
题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...
- 03.14 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019
A .Architecture 题意:其实就是想让你找到两行数的最大值,然后比较是否相同,如果相同输出'possible',不同则输出'impossible' 思路:直接遍历寻找最大值,然后比较即可 ...
- Gym -102007 :Benelux Algorithm Programming Contest (BAPC 18) (寒假自训第5场)
A .A Prize No One Can Win 题意:给定N,S,你要从N个数中选最多是数,使得任意两个之和不大于S. 思路:排序,然后贪心的选即可. #include<bits/stdc+ ...
- 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...
- 计蒜客 28317.Growling Gears-一元二次方程的顶点公式 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 G)
G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include& ...
- 计蒜客 28315.Excellent Engineers-线段树(单点更新、区间最值) (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 E)
先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到 ...
随机推荐
- Dockerfile 实践及梳理
Dockerfile 是一个文本文件,我们可以通过组合一条条的指令 (Instruction),来构建满足我们需求的 Docker 镜像 文档 Best practices for writing D ...
- AI使用之技巧
学习人脸关键点检测的收获: 可以将高难度关键点定位任务,其拆成多个小任务,逐步细化精度,每一层都是小网络,相比用一个复杂大网络,更能节省predict的运行时间. 数据增强Data Augmentat ...
- inotify与rsync实现实时同步记录文档
目录 安装 配置 参考链接 安装 安装rsync yum -y install rsync 安装inotify-tools 这是一个实时监听文件变换的工具 wget -O /etc/yum.repos ...
- 剑指 Offer 32 - I. 从上到下打印二叉树
剑指 Offer 32 - I. 从上到下打印二叉树 从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印. 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 ...
- 如何实现LRU缓存?
面试官:来了,老弟,LRU缓存实现一下? 我:直接LinkedHashMap就好了. 面试官:不要用现有的实现,自己实现一个. 我:..... 面试官:回去等消息吧.... 大家好,我是程序员学长,今 ...
- 【CSS】拼图验证练习
抄自B站Up主CodingStartup起码课 <!DOCTYPE html> <html lang="en"> <head> <meta ...
- Java基础(四)——抽象类和接口
一.抽象类 1.介绍 使用关键字 abstract 定义抽象类. abstract定义抽象方法,只有声明,不用实现. 包含抽象方法的类必须定义为抽象类. 抽象类中可以有普通方法,也可以有抽象方法. 抽 ...
- shell中的引号
单引号: 所见即所得 原封不动输出 双引号: 与单引号类似 特殊符号进行解析 ( $ $() `` ! ) 无引号: 与双引号类似 支持通配符( {} * ) 反引号: 优先执行 优先执行里面的命令, ...
- 快速模式第三包:quick_inR1_outI2()
快速模式第三包:quick_inR1_outI2() 文章目录 快速模式第三包:quick_inR1_outI2() 1. 序言 2. quick_inR1_outI2()的处理流程 3. 快速模式第 ...
- 硕盟SM-T54|type-c转接头HDMI+VGA+USB3.0+PD3.0四合一多功能扩展坞接口功能说明
硕盟SM-T54是一款 TYPE C转HDMI+VGA+USB3.0+PD3.0四合一多功能扩展坞,支持四口同时使用,您可以将含有USB 3.1协议的电脑主机,通过此产品连接到具有HDMI或VGA的显 ...