1.第一题 没有看

2. 由于数据范围很小,所以每一层需要全排列,寻找最小的花费,然后所有层加起来就是最后的结果。

 #include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + ;
int n;
int m;
int a[][][];
int p[]; void solve() {
cin >> n >> m;
ll res = ;
for (int j = ; j < n; j++) {
cin >> a[][j][] >> a[][j][];
}
for (int i = ; i <= m; i++) {
for (int j = ; j < n; j++) {
cin >> a[i][j][] >> a[i][j][];
}
if(i == ) continue;
for (int j = ; j < n; j++)
p[j] = j;
ll mr = INT_MAX;
do {
ll t = ;
for (int j = ; j < n; j++) {
t += abs(a[i][p[j] ][] - a[i - ][j][] ) + abs(a[i][p[j] ][] - a[i - ][j][] );
}
mr = min(t, mr);
} while(next_permutation(p, p + n));
res += mr;
}
cout << res << endl; } int main() {
freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

3.数据范围也是很小,枚举每一条边,然后存在不存在,进行判断累加。边的个数6 * 5  / 2 = 15. 1 << 15 = 32000. 然后乘上判断连通的复杂度,结果也是很小。

判断连通可以用bfs或者dfs, dsu都是可以的。

 #include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + ;
int n, m;
//set<pii> se;
int f[];
int a[][];
int b[][];
void init() {
for (int i = ; i <= n; i++) f[i] = i;
}
int fd(int x) {
if(x == f[x]) return x;
return f[x] = fd(f[x]);
}
bool check() {
int sz = n;
for (int i = ; i <= n; i++) {
for (int j = i + ; j <= n; j++) {
if(a[i][j]) {
int t1 = fd(i);
int t2 = fd(j);
if(t1 != t2) {
sz--;
f[t1] = t2;
}
}
}
}
return sz == ;
}
ll res; void work(int x, int y) {
//cout << x << " " << y << endl;
if(x > n) {
init();
res += check();
return;
}
if(y > n) {
work(x + , x + );
return;
}
work(x, y + );
if(b[x][y]) return;
a[x][y] = a[y][x] = ;
work(x, y + );
a[x][y] = a[y][x] = ;
}
void solve() {
cin >> n >> m;
int x, y;
for (int i = ; i < m; i++) {
cin >> x >> y;
//if(x > y) swap(x, y);
//se.insert({x, y});
b[x][y] = b[y][x] = ;
}
work(, );
cout << res << endl;
} int main() {
freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

4. 第四题稍微花了一些时间。 首先题目求解满足条件的最小, 那就是比这个大的都是可以满足条件的, 满足二分的性质。

然后给定答案,如何快速的判断是否满足要求, 贪心策略进行。由于 n = 1e4, 这个数其实挺小的, 排序, 贪心 可以的。

 #include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e4 + ;
int n, a, b;
ll h[maxn];
ll tmp[maxn];
int tot;
bool check(ll x) {
ll ra, rb;
ra = rb = ;
tot = ;
for (int i = ; i < n; i++) {
if(h[i] >= x) {
ll c = h[i] / x;
if(ra + c > a) {
ll t = h[i] - x * (a - ra);
ra = a;
if(t > ) tmp[tot++] = t;
} else {
ra += h[i] / x;
int t = h[i] % x;
if(t > ) tmp[tot++] = t;
} } else {
tmp[tot++] = h[i];
}
//if(ra > a) return 0;
}
sort(tmp, tmp + tot, greater<ll>());
for (int i = ; i < tot; i++) {
if(ra < a) {
ra++;
} else {
rb += tmp[i];
}
}
return ra + rb <= b;
}
void solve() {
cin >> n >> a >> b;
for (int i = ; i < n; i++) {
cin >> h[i];
}
sort(h, h + n, greater<ll>());
ll left = , right = 1e9 + ;
while(left < right) {
ll mid = (left + right) / ;
//cout << mid << " " << left << " " << right << endl;
if(check(mid)) right = mid;
else left = mid + ; }
if(check(left)) cout << left << endl;
else cout << - << endl;
} int main() {
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

indeed 4.22 第一次网测的更多相关文章

  1. indeed2017校招在线编程题(网测)三

    A. Calculate Sequence 分析:就是斐波那契递推公式,但是初始值是指定的,只用求第10个数,数据范围和复杂度都比较小,直接写. B. 忘了叫啥了. 就是有a-j十个字符组成的字符串, ...

  2. 2014-CVTE网测部分软件技术测试题及答案

    1.叉树的先序遍历序列和后序遍历序列正好相反,则该二叉树满足的条件是(D) A.空或只有一个结点 B.高度等于其结点数 C.该二叉树是完全二叉树 D.所有结点无右孩子 应该是二叉树的每个结点都只有一个 ...

  3. wap网测一道题目

    1. 给定一个字符串s, 1 <= len(s) <= 3000, 定义odd palindrome string为长度为奇数的回文串, 求s中该奇回文串的个数. 比如axbcba , 结 ...

  4. wap 5.23 网测几道题目

    1. n个犯人,m个省份, 如果相邻的2个犯人来自同一省份,则是不安全的,求不安全的个数. 正难则反,用全部的个数减去非法的个数,就是最后的答案. m^n - m * (m - 1) ^ (n - 1 ...

  5. 5.27 indeed 第三次网测

    1. 第一题, 没有看 2. 暴力枚举.每一个部分全排列, 然后求出最大的请求数. #include<bits/stdc++.h> #define pb push_back typedef ...

  6. indeed 5.13 第二次网测

    题目描述,我找不见了,大概写一下想法和代码吧. 1. 没有看 2. 由于数据范围很小,就是简单的枚举,求全排列,然后更新答案. #include<bits/stdc++.h> #defin ...

  7. elasticsearch系列(二) esrally压测

    环境准备 linux centOS(工作环境) python3.4及以上 pip3 JDK8 git1.9及以上 gradle2.13级以上 准备过程中的坑 这些环境准备没什么太大问题,都是wget下 ...

  8. mysql每秒最多能插入多少条数据 ? 死磕性能压测

    前段时间搞优化,最后瓶颈发现都在数据库单点上. 问DBA,给我的写入答案是在1W(机械硬盘)左右. 联想起前几天infoQ上一篇文章说他们最好的硬件写入速度在2W后也无法提高(SSD硬盘) 但这东西感 ...

  9. 使用Holer外网SSH访问内网(局域网)Linux系统

    1. Holer工具简介 Holer exposes local servers behind NATs and firewalls to the public internet over secur ...

随机推荐

  1. mysql异地备份方案经验总结

    Mysql 数据库异地备份脚本 实验环境:关闭防火墙不然不能授权登录 Mysql-server:192.168.30.25 Mysql-client:  192.168.30.24 实验要求:对mys ...

  2. demo_static_resrouce

    环境 win10 + webstorm 2019.1.3 + node 12.x + yarn 实现的的功能 基本的js打包(支持规范:ES6 module | requirejs | commonj ...

  3. java中一个数组不能放不同数据类型的值

    在java中,数组不能放不同数据类型的值. 方法一: 多态 定义数组类型的时候定义为父类,而存进数组为父类的子类 public class test2 { public static void mai ...

  4. maven常用dos命令

    在平常的开发中可能会经常切换开发中的一些工具,有时就会对一些常用的命令给忘记了 这里特别记录下来方便以后使用: 1.查看maven版本:mvn -c 2.一件构建启动Tomcat:mvn tomcat ...

  5. 18清明校内测试T3

    扫雷(mine) Time Limit:1000ms   Memory Limit:128MB 题目描述 rsy最近沉迷于一款叫扫雷的游戏. 这个游戏是这样的.一开始网格上有n*m个位置,其中有一些位 ...

  6. exgcd扩展欧几里得求解的个数

    知识储备 扩展欧几里得定理 欧几里得定理 (未掌握的话请移步[扩展欧几里得]) 正题 设存在ax+by=gcd(a,b),求x,y.我们已经知道了用扩欧求解的方法是递归,终止条件是x==1,y==0: ...

  7. python--(socket与粘包解决方案)

    python--(socket与粘包解决方案) 一.socket: Socket 是任何一种计算机网络通讯中最基础的内容.例如当你在浏览器地址栏中输入 http://www.cnblogs.com/ ...

  8. 第五节:web爬虫之urllib(一)

    一.urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False,    ...

  9. ajax学习----json,前后端交互,ajax

    json <script> var obj = {"name": "xiaopo","age": 18,"gender ...

  10. 【Codeforces 1106D】Lunar New Year and a Wander

    [链接] 我是链接,点我呀:) [题意] 让你遍历n个节点,访问过的节点不操作. 如果是没有访问过的点,那就把它加到序列的末尾. 问你形成的最小字典序的序列是多少. [题解] 显然每次找最小的标号 用 ...