Water The Garden

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int x[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n, k, t;
cin >> t;
while (t--) {
cin >> n >> k;
int ans = ;
for (int i = ; i < k; i++) cin >> x[i];
ans = max(ans, x[]);
ans = max(ans, n - x[k - ] + );
for (int i = ; i < k; i++) ans = max(ans, (x[i] - x[i - ] + ) / );
cout << ans << endl;
}
return ;
}

Tea Queue

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int l[], r[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n, t;
cin >> t;
while (t--) {
cin >> n;
for (int i = ; i < n; i++) cin >> l[i] >> r[i];
int time = ;
for (int i = ; i < n; i++) {
if (time < l[i]) time = l[i];
if (time > r[i]) {
cout << << ' ';
continue;
}
cout << time << ' ';
time++;
}
cout << endl;
}
return ;
}

Swap Adjacent Elements

显然一段1+0子段是可以变换为任意顺序的,而各个1+0中间单独存在的0必须满足a[i]=i时才能完成排序。对于某一段1+0子段,假设对应区间为a[i]~a[j]由于它无法与其他子段发生交换,所以a[i]~a[j]中的数字必须由i~j组成。

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int a[], p[], b[];
bool f[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n;
cin >> n;
for (int i = ; i <= n; i++) {
cin >> a[i];
p[a[i]] = i;
}
char ch;
for (int i = ; i < n; i++) {
cin >> ch;
b[i] = ch - '';
}
b[n] = ;
bool ok = true;
int ptr = ;
while (ptr <= n) {
if (b[ptr] == ) {
if (a[ptr] != ptr) ok = false;
ptr++;
} else {
int l = ptr;
while (b[ptr] == ) ptr++;
int r = ptr;
for (int i = l; i <= r; i++) f[i] = false;
for (int i = l; i <= r; i++) f[a[i]] = true;
for (int i = l; i <= r; i++) if (!f[i]) ok = false;
ptr++;
}
}
if (ok) cout << "YES" << endl;
else cout << "NO" << endl;
return ;
}

Tanks

如果所有的水箱中水量加起来不到v,则方案不存在。

首先选出若干个水箱,他们当前的水量加起来与v对k取余相同,若选不出来,则方案不存在。

对于选出的水箱,首先把这部分水箱中的水集中在一起,然后把其余的水箱中的水集中在一起,然后再舀回若干次k即可。

代码鸽了。

Connected Components

观察一下这个数据,其实挺搞笑的。对于小数据,怎么搞都可以。对于n和m都是20w的大数据,其答案肯定是199990+和几个一位数组成。

对于大小是S1和S2的两个强联通分量,其中的不直连关系至少要有S1*S2个。对于给定条件,每个点都缺少若干条边,其中有一个缺少的边数量最少的点,设为r,r缺边数量设为p。p能有多少呢?如果p能上万,那有缺边现象的点就不会超过20个。所以p估计也就是个四五百顶天了,那么最大的一个强联通分量就已经直接预订了这(n-四五百)这么多的点。

对于剩下的点,先不考虑外面,把他们内部的强连通分量分别算出来,然后对于每个强联通分量,如果其中一个点有连向外部的边,那么它属于最大的强联通分量的一部分,否则就是一个独立的真强联通分量。

代码鸽了

SUM and REPLACE

List of  Integers

[Codeforces]Educational Codeforces Round 37 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 37 (Rated for Div. 2)C. Swap Adjacent Elements (思维,前缀和)

    Educational Codeforces Round 37 (Rated for Div. 2)C. Swap Adjacent Elements time limit per test 1 se ...

  2. Educational Codeforces Round 37 (Rated for Div. 2) 920E E. Connected Components?

    题 OvO http://codeforces.com/contest/920/problem/E 解 模拟一遍…… 1.首先把所有数放到一个集合 s 中,并创建一个队列 que 2.然后每次随便取一 ...

  3. Educational Codeforces Round 37 (Rated for Div. 2)

    我的代码应该不会被hack,立个flag A. Water The Garden time limit per test 1 second memory limit per test 256 mega ...

  4. Educational Codeforces Round 37 (Rated for Div. 2) G

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  5. Educational Codeforces Round 37 (Rated for Div. 2) E. Connected Components? 图论

    E. Connected Components? You are given an undirected graph consisting of n vertices and edges. Inste ...

  6. Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序

    Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你 ...

  7. 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 ...

  8. 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 ...

  9. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

随机推荐

  1. mysql安装包下载地址

    1.打开mysql官网 :https://dev.mysql.com/ 2.选择 downlad-->windows-->MySQL Installer -->滑动至页面底部,选择第 ...

  2. python tips:类的专有属性

    实例通常能够调用类的属性,但是有些属性是类专有的,实例无法调用. 实例调用方法时查找属性时,首先在自己的__dict__中找,找不到去类中找,在类中能够找到的属性都位于dir(cls)中,如果类的某些 ...

  3. day11 前端知识简单总结

    目录 1.html常用标签 2.css布局 一. html 常用标签 1.head里面的标签,仅仅应用于网页的一些基础信息 1.1  meta 属性http-equiv 向浏览器传达一些有用的信息 与 ...

  4. 【转载】Jsp页面传Json数据到服务端,转对象或集合进行数据处理

    需求:1.将页面数据带到服务端并转成对象,2.将页面的集合数据带到服务端转List实现:用ajax请求传递数据,数据格式为json JS方法: testJsonMethod = function(){ ...

  5. 一个休假申请页对input标签各种属性的用法案例(手机端)

    <%@ page language="java" import="java.util.*" contentType="text/html; ch ...

  6. Day7 字符串和常用数据结构

    字符串和常用数据结构 使用字符串 第二次世界大战促使了现代电子计算机的诞生,当初的想法很简单,就是用计算机来计算导弹的弹道,因此在计算机刚刚诞生的那个年代,计算机处理的信息主要是数值,而世界上的第一台 ...

  7. 关于如何利用js判断IE浏览器各种版本问题

    <!--[if IE 6]> IE 浏览器版本 6 <![endif]-->   <!--[if IE 7]> IE 浏览器版本 7 <![endif]--& ...

  8. HDU2866 Special Prime

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2866 题意:在区间[2,L]内,有多少个素数p,满足方程有解. 分析: 原方程变为: n^(b-1) ...

  9. [luogu2576 SCOI2010] 幸运数字 (容斥原理)

    传送门 Description 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的"幸运号码"是十进制表示中只包含数字6和8的那些号码,比如68,66 ...

  10. vue自定义指令clickoutside扩展--多个元素的并集作为inside

    都是个人理解,如果发现错误,恳请大家批评指正,谢谢.还有我说的会比较啰嗦,因为是以自身菜鸡水平的视角来记录学习理解的过程,见谅. 1.前言 产品使用vue+element作为前端框架.在功能开发过程中 ...