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中的某一个比已存在的人中的小,就把这个人添加到 ...
随机推荐
- 实例说明C++的virtual function的作用以及内部工作机制初探
C++为何要引入virtual function? 来看一个基类的实现: 1 class CBase 2 { 3 public: 4 CBase(int id) : m_nId(id), m_pBas ...
- JavaScript——数组——slice方法
JavaScript--数组--slice方法 JavaScript中的slice方法类似于字符串的substring方法,作用是对数组进行截取. slice方法有两个参数,indexStart 和 ...
- Centos8.3安装broadcom(博通)BCM43142无线网卡驱动,Centos8没有wifi选项(No wifi adapter found centos)解决办法
参考:杆菌大祭司> https://www.jianshu.com/p/3cb41b7b8fec 第一步:查看网卡型号,确认无线网卡型号为BCMXXX lspci | grep Network ...
- uniapp H5 打包并部署到 nginx
个人也是了百度了挺久的了,花费的时间( 俩个半小时 ) uniapp 的打包首先要先配置,配置好了才能去进行打包,如图所示. 这只是第一步. 注意: 1.运行基础路径最好用 ./ ,如果配置了其他请自 ...
- shell循环语句until
until 条件 do 执行命令 done until 循环与 while 循环在处理方式上刚好相反. 当条件成立的时候,停止循环.
- 20210717 noip18
考前 从小饭桌出来正好遇到雨下到最大,有伞但还是湿透了 路上看到一个猛男搏击暴风雨 到了机房收拾了半天才开始考试 ys 他们小饭桌十分明智地在小饭桌看题,雨下小了才来 考场 状态很差. 开题,一点想法 ...
- LCT 小记
全程 Link-Cut Tree,是解决动态树问题的有力科技 --题记 简单实现 LCT 的形态直观上是一堆 Splay 的合体,每个 Splay 以时间戳为关键字,各个 Splay 通过虚边相连,可 ...
- Python - 面向对象编程 - __init__() 构造方法
什么是构造方法 在创建类时, 可手动添加一个 __init__() 方法,称为构造方法,这是一个实例方法 构造方法用于创建实例对象时使用,每当创建一个类的实例对象时,Python 解释器都会自动调 ...
- Nacos注册中心之概要设计
本文已收录 https://github.com/lkxiaolou/lkxiaolou 欢迎star. 前言 在之前的文章中分析了Nacos配置中心,配置中心的核心是配置的创建.读取.推送. 注册中 ...
- Mybatis log plugin插件破解修复版 MyBatis Log Plugin License Authorization Failed
github地址 - https://github.com/Link-Kou/intellij-mybaitslog