RCC 2014 Warmup (Div. 2) 蛋疼解题总结
1 second
256 megabytes
standard input
standard output
The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.
The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.
As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at leastn·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.
The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners.
In the first line, print a single integer — the minimum number of problems the jury needs to prepare.
1 10
7 2
1
2
2 2
2 1
2
0
题意:为了进final举办淘汰赛,赛制有两种,一种是取前n个人晋级,需要用c个题目,另一种是取第一名需要c个题目,每次比赛都会特别邀请k个人,问选m*n个人最少
用多少题目。
sl: 没有更水的了,可惜开始没读懂题。对于最后余下的不足n的人数只要比较left*d和c的大小就好了, 其余的比较n*d和c的大小就好了。
1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #include<vector>
5 #include<queue>
6 using namespace std;
7 const int MAX = 1e3+;
8 int main()
9 {
int c,d,n,m,k; int ans;
while(scanf("%d %d",&c,&d)==)
{
ans=;
scanf("%d %d",&n,&m); scanf("%d",&k);
int tot=n*m-k;
if(tot<=) printf("0\n");
else
{
int x=tot/m; int cnt=tot/n; int cc=tot%n;
if(n*d<=c) ans=n*cnt*d;
else ans=c*cnt;
if(cc*d<c) ans+=cc*d;
else ans+=c;
printf("%d\n",ans);
}
}
return ;
}
1 second
256 megabytes
standard input
standard output
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
2
0 1
1 1
YES
4
0 1
1 2
1 1
0 2
NO
4
0 1
1 1
0 1
0 2
YES
题意:就是给出每个人的编号和提交顺序,问是不是按时间顺序给出的(每个人的代码号都是从0开始递增的和别人无关)
sl:根据题意只要判断每个人的代码号书不是在前面出现过,没出现过的话直接判断是不是跟上一个数字连续就行。
1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #include<vector>
5 #include<queue>
6 #include<set>
7 using namespace std;
8 const int MAX = 1e5+;
9 vector<int> G[MAX];
set<int> cnt[MAX];
int main()
{
int n; int x,k;
while(scanf("%d",&n)==)
{
int flag=;
for(int i=;i<n;i++)
{
scanf("%d %d",&x,&k);
int m=G[k].size();
if(!m)
{
if(x==) G[k].push_back(x),cnt[k].insert(x);
else flag=,G[k].push_back(x),cnt[k].insert(x);
}
else if(cnt[k].count(x)) continue;
else if(G[k][m-]==x-) G[k].push_back(x),cnt[k].insert(x);
else flag=;
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return ;
34 }
1 second
256 megabytes
standard input
standard output
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.
The appointed Judge was the most experienced member — Pavel. But since he was the wisest of all, he soon got bored of the game and fell asleep. Waking up, he discovered that the tournament is over and the teams want to know the results of all the matches.
Pavel didn't want anyone to discover about him sleeping and not keeping an eye on the results, so he decided to recover the results of all games. To do this, he asked all the teams and learned that the real winner was friendship, that is, each team beat the other teams exactly k times. Help Pavel come up with chronology of the tournir that meets all the conditions, or otherwise report that there is no such table.
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won against the team with number bi. You can assume, that the teams are numbered from 1 to n.
If a tournir that meets the conditions of the problem does not exist, then print -1.
3 1
3
1 2
2 3
3 1
题意:有n个小组,每个小组要进行k场比赛并且每次只能和对手比一场,给出对战表。
sl:可以暴力过,也可以两个for循环过。(当时着急了直接暴力做的10min1Y)
1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #include<vector>
5 #include<queue>
6 using namespace std;
7 const int MAX = 1e3+;
8 int vis[MAX][MAX],ans[MAX];
9 vector<int> G[MAX];
int main()
{
int n,k,tot;
while(scanf("%d %d",&n,&k)==)
{
tot=;
memset(vis,,sizeof(vis));
memset(ans,,sizeof(ans));
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++) if(i!=j)
{
if(ans[i]==k) break;
if(!vis[i][j])
{
tot++;
vis[i][j]=vis[j][i]=;
ans[i]++;
G[i].push_back(j);
}
}
}
int flag=;
for(int i=;i<=n;i++) if(ans[i]!=k) flag=;
if(!flag) printf("-1\n");
else
{
printf("%d\n",tot);
for(int i=;i<=n;i++) for(int j=;j<G[i].size();j++)
printf("%d %d\n",i,G[i][j]);
}
}
return ;
43 }
1 second
256 megabytes
standard input
standard output
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xi, ki and mi (1 ≤ xi ≤ 109; 1 ≤ ki ≤ 109; 1 ≤ mi ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
2 2 1
100 1 1
2
100 2 1
1
202
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
205
1 2 1
1 1 1
1
-1
题意:有m个问题,同时有n个人每个人能解决mi个问题,雇佣这个人花xi元,并且这个人需要ki个显示器,每个显示器b元。问解决m个问题最少花费多少钱
sl:看上去有点想背包。可以把问题个数想成背包容量,就是一个0-1背包。需要按显示器的个需求排序,因为同样解决m个问题用的显示器越少越好么。
状态方程 dp[state|cover]=min(dp[state|cover],dp[state]+x);
1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 using namespace std;
5 typedef long long LL;
6 const int MAX = <<;
7 const LL inf = 1LL<<;
8 struct P
9 {
int x,k,m;
int cover;
bool operator < (const P &rhs) const
{
return k<rhs.k;
}
} v[];
LL dp[MAX];
int main()
{
int n,m,b; int a;
while(scanf("%d %d %d",&n,&m,&b)==)
{
for(int i=;i<n;i++)
{
scanf("%d %d %d",&v[i].x,&v[i].k,&v[i].m); v[i].cover=;
for(int j=;j<v[i].m;j++)
{
scanf("%d",&a); v[i].cover|=(<<(a-));
}
}
sort(v,v+n);
for(int j=;j<=(<<m)-;j++) dp[j]=inf;
dp[]=;
LL ans=inf;
for(int i=;i<n;i++)
{
for(int j=((<<m)-);j>=;j--)
{
dp[j|v[i].cover]=min(dp[j|v[i].cover],dp[j]+v[i].x);
}
if(dp[(<<m)-]!=inf)
ans=min(ans,dp[(<<m)-]+(LL)v[i].k*(LL)b);
}
if(ans>=inf) printf("-1\n");
else printf("%I64d\n",ans);
}
return ;
51 }
1 second
256 megabytes
standard input
standard output
While resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size n × m, consisting of positive integers such that the sum of the squares of numbers for each row and each column was also a square.
Since checking the correctness of the table manually is difficult, Misha asks you to make each number in the table to not exceed 108.
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the size of the table.
Print the table that meets the condition: n lines containing m integers, separated by spaces. If there are multiple possible answers, you are allowed to print anyone. It is guaranteed that there exists at least one correct answer.
1 1
1
1 2
3 4
题意:很鸟蛋的一体,就是给出矩阵的行列,叫你给出一个矩阵,满足每一行的平方和仍然是某一个数的平方。每一列的平方和仍然是某一个数的平方。
sl:数学构造了,看了下别人的题解都是千奇百怪的,都很神奇有一个是这么写的
先构造出一个一维的长度为n的序列在用同样的方法构造出长度为m的序列 然后用长度为n的每一个元素去乘 长度为m的每个元素
构造出n*m个数字。
构造方法是:前n-1个(m个)数字为2最后一个是(n-2)(或 (m-2)) 可以证明确实正确。
附别人题解报告一份。
http://codeforces.com/contest/417/submission/6398158
RCC 2014 Warmup (Div. 2) 蛋疼解题总结的更多相关文章
- RCC 2014 Warmup (Div. 2)
一场很很多HACK的比赛,PREtest太弱了,真的很多坑!平时练习的时候很少注意这些东西了! A:开始一直在模拟,后来发现自己的思路逻辑很乱,果然做比赛不给力! 直接在代码中解释了 #include ...
- RCC 2014 Warmup (Div. 2) ABC
题目链接 A. Elimination time limit per test:1 secondmemory limit per test:256 megabytesinput:standard in ...
- RCC 2014 Warmup (Div. 2) A~C
近期CF的pretext真是一场比一场弱.第一次在CF上被卡cin.cout.... A. Elimination time limit per test 1 second memory limit ...
- RCC 2014 Warmup (Div. 1)
A 暴力 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm& ...
- Codeforces Round 319 # div.1 & 2 解题报告
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...
- Codeforces Round #342 (Div 2) 解题报告
除夕夜之有生之年CF第一场 下午从奶奶家回到姥姥家,一看还有些时间,先吃点水果陪姥姥姥爷聊了会儿,再一看表,5:20....woc已经开场20分钟了...于是抓紧时间乱搞.. **A. Guest F ...
- Codeforces Round #232 (Div. 1) A 解题报告
A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...
- [Codeforces Round #194 (Div. 2)] Secret 解题报告 (数学)
题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S ...
- CodeForces - 417E(随机数)
Square Table Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
随机推荐
- 在数据库中生成txt文件到网络驱动器中(计算机直接创建的网络驱动器在sql server中没有被找到)
环境:sql server 2008 一.创建网络驱动器映射 语法:exec master..xp_cmdshell 'net use Z: \\ip地址\网络路径 密码 /user:用户名' 例如: ...
- poj Find a multiple【鸽巢原理】
参考:https://www.cnblogs.com/ACShiryu/archive/2011/08/09/poj2356.html 鸽巢原理??? 其实不用map但是习惯了就打的map 以下C-c ...
- bzoj3450 Easy(概率期望dp)
3450: Tyvj1952 Easy Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 876 Solved: 648[Submit][Status] ...
- Akka源码分析-Cluster-Metrics
一个应用软件维护的后期一定是要做监控,akka也不例外,它提供了集群模式下的度量扩展插件. 其实如果读者读过前面的系列文章的话,应该是能够自己写一个这样的监控工具的.简单来说就是创建一个actor,它 ...
- linux C编程 gdb的使用
linux C编程 gdb的使用 通常来说,gdb是linux在安装时自带的,在命令行键入"gdb"字符并按回车键会启动gdb调试环境. 1.gdb的基本命令 命令 说明 file ...
- Enumerable.Union<TSource> 方法
功能:生成两个序列的并集(使用默认的相等比较器). 命名空间: System.Linq 程序集: System.Core.dll 备注:实现此方法时使用了延迟执行. 它直接返回一个对象,该对象存储了执 ...
- python2行代码调用程序
import win32api win32api.ShellExecute(0, 'open', r'C:\Users\TOPFEEL\AppData\Local\Postman\app-5.5.0\ ...
- 295 Find Median from Data Stream 数据流的中位数
中位数是排序后列表的中间值.如果列表的大小是偶数,则没有中间值,此时中位数是中间两个数的平均值.示例:[2,3,4] , 中位数是 3[2,3], 中位数是 (2 + 3) / 2 = 2.5设计一个 ...
- bnu 51640 Training Plan DP
https://www.bnuoj.com/bnuoj/problem_show.php?pid=51640 dp[i][j]表示前j个数,分成了i组,最小需要多少精力. 那么,求解订票dp[i][j ...
- 【转】MySQL常见的运算符及使用
转自:http://www.linuxidc.com/Linux/2016-03/129672.htm MySQL中有4类运算符,它们是: 算术运算符 比较运算符 逻辑运算符 位操作运算符 算术操作符 ...