Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)
现在水平真的不够、只能够做做水题
A. Slime Combining
题意:就是给n个1给你、两个相同的数可以合并成一个数,比如说有两个相同的v,合并后的值就是v+1
思路:直接模拟栈
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int num[];
int main()
{
int n;
while(cin >> n){
stack<int>p;
p.push();
for(int i=;i<n;++i){
p.push();
int x,y;
while(p.size()>=){
x=p.top();p.pop();
y=p.top();p.pop();
if(x==y)
p.push(x+);
else{
p.push(y);p.push(x);
break;
}
}
}
int k=;
while(!p.empty()){
num[k++]=p.top();
p.pop();
}
for(int i=k-;i>=;--i)
if(i==k-) cout << num[i];
else cout << " " << num[i];
cout << endl;
}
}
B. Guess the Permutation
这题还想了好久、其实想通了就很简单了
题意:给你一个正方形的数值阵,每一个数值阵中的值map[i][j]=min(a[i],a[j]),也就是值是两者中较小的一个,数组a是一个序列,让你通过这个数值阵去还原数组a
思路:每一行中如果不同的元素个数等于n个,那么这个序列除了0以为其他的数值就是数组a中的序列数,剩下的只要把0改成n就可以了
还一种思路(被人家教育了)就是每一行中的最大值其实就是数组a[i]的值、但需要注意n-1的n,(思考)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
const int qq=;
int map[qq][qq];
int main()
{
set<int>p[qq];
int n;scanf("%d",&n);
for(int j,i=;i<=n;++i){
for(j=;j<=n;++j){
scanf("%d",&map[i][j]);
p[i].insert(map[i][j]);
}
}
int ans;
for(int i=;i<=n;++i)
if(p[i].size()==n){
ans=i;break;
}
for(int i=;i<=n;++i){
if(i==)
if(map[ans][i]!=) printf("%d",map[ans][i]);
else printf("%d",n);
else
if(map[ans][i]!=) printf(" %d",map[ans][i]);
else printf(" %d",n);
}
printf("\n");
}
#include<iostream>
using namespace std;
int main()
{
int n,f=;
cin>>n;
for(int i=;i<n;i++){
int m=;
for(int j=;j<n;j++)
{
int x;
cin>>x;
m=max(m,x);
}
if(m==n- && f)
{
f=;
m+=;
}
cout<<m<<" ";
} return ;
}
说白了B题就是找规律、- - 以后不能这么傻了
Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)的更多相关文章
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) B. Guess the Permutation 水题
B. Guess the Permutation 题目连接: http://www.codeforces.com/contest/618/problem/B Description Bob has a ...
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) A. Slime Combining 水题
A. Slime Combining 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2768 Description Your frien ...
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) F. Double Knapsack 鸽巢原理 构造
F. Double Knapsack 题目连接: http://www.codeforces.com/contest/618/problem/F Description You are given t ...
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) E. Robot Arm 线段树
E. Robot Arm 题目连接: http://www.codeforces.com/contest/618/problem/E Description Roger is a robot. He ...
- CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort 暴力枚举,水 1.题意:n*m的数组, ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
随机推荐
- zoj 1028 Flip and Shift(数学)
Flip and Shift Time Limit: 2 Seconds Memory Limit: 65536 KB This puzzle consists of a random se ...
- Sass @at-root (1)
在SassConf大会上,给我们传递了Sass3.3的新特性.这些新特性有很多意义,特别是@at-root指令,这让你的代码会得更佳清洁. 今天我们主要一起来了解Sass中的@at-root特性的使用 ...
- BZOJ 4817数点涂色题解
题目链接 考试考了一道类似的题目,然后不争气的挂掉了,于是跑过来学习这道题的解法... 我还是太菜了.... 我们可以发现任意时刻,原树中颜色相同的点的集合一定是一条链, 即上面这种状态,而这种结构是 ...
- mac上SVN的图形工具 SmartSVN注册
mac上SVN的图形工具 SmartSVN注册 打开smartsvn,选中license注册 选中文件smartsvn.license,下一步下一步就ok了 smartsvn.license Name ...
- cocos2dx3.0项目创建流程
cocos2dx3.0不是beta,新增了wp项目创建的支持 但不知道为啥非beta版本号的tools文件夹中取消了project-creator,可能有更改吧 没有这个工具还挺麻烦.就自己手动创建c ...
- Effective Modern C++:05右值引用、移动语义和完美转发
移动语义使得编译器得以使用成本较低的移动操作,来代替成本较高的复制操作:完美转发使得人们可以撰写接收任意实参的函数模板,并将其转发到目标函数,目标函数会接收到与转发函数所接收到的完全相同的实参.右值引 ...
- 【JZOJ4855】【NOIP2016提高A组集训第6场11.3】荷花池塘
题目描述 于大夫建造了一个美丽的池塘,用来让自己愉快的玩耍.这个长方形的池子被分割成了M 行 和N 列的正方形格子.池塘中有些地方是可以跳上的荷叶,有些地方是不能放置荷叶也不 能跳上的岩石,其他地方是 ...
- poj1087&&hdu1526 最大流
多源多汇. 比较明显的建图.对于电器,可以从源点与各个电器相连,容量为1,表示这个电器有1个,然后对于各种接头,那可以各个接头与汇点相连,容量为1,表示每个接头只能用一次. 然后对于能够相互转换的接头 ...
- 反射技术的入口 获取类的Class信息
package com.sxt.reflect; import com.sxt.reflect.entity.Student; /* * 获取类的Class信息 */ public class Tes ...
- map的三种遍历方法!
map的三种遍历方法! 集合的一个很重要的操作---遍历,学习了三种遍历方法,三种方法各有优缺点~~ /* * To change this template, choose Tools | Te ...