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. HTTP协议探索之Cache-Control

    缓存的存与用的控制 Cache-Control指定了请求和响应遵循的缓存机制.好的缓存机制可以减少对网络带宽的占用,可以提高访问速度,提高用户的体验,还可以减轻服务器的负担. Cache-Contro ...

  2. Html 页面刷新后出现闪动

    Html 页面刷新后,或跳转后,出现闪动,抖动问题 1.查看有没有用到新字体,新字体链接位置是否存在 如: @font-face { font-family: "AvantGarde-Dem ...

  3. Linux 僵尸进程如何处理

    Linux 允许进程查询内核以获得其父进程的 PID,或者其任何子进程的执行状态.例如,进程可以创建一个子进程来执行特定的任务,然后调用诸如 wait() 这样的一些库函数检查子进程是否终止.如果子进 ...

  4. Coloring Flame Graphs: Code Hues

    转自:http://www.brendangregg.com/blog/2017-07-30/coloring-flamegraphs-code-type.html I recently improv ...

  5. URAL - 1114-Boxes (分步乘法原理)

    题意; 给你n个盘子,A个红球,B个黑球,放的时候没有限制,可以不放,可以放一个红球,可以放一个黑球,也可以两个同时放,可以有剩余的球. 求一共有多少放法. 思路: 可以利用分步乘法原理,红球和黑球是 ...

  6. 08.Web服务器-5.深入理解HTTP协议(大图)

  7. Codeforces 899C - Dividing the numbers

    传送门:http://codeforces.com/contest/899/problem/C 本题是一个数学问题——集合划分. 将集合{1,2,...,n}划分成两个集合,使得两个集合的元素之和的绝 ...

  8. 调用的方法里接收一个List<>类型的参数,里面是自定义的EC类, 我要通过反射构建这List对象

              public static object CreateGeneric(Type generic, Type innerType, params object[] args)     ...

  9. 生成PW配置和BFD配置

    保存在配置文件中 def Main(): buf = '' f = open('pw.cfg','w') for i in range(2016): pwid = str(102 + i) buf + ...

  10. (20)Spring Boot Servlet【从零开始学Spring Boot】

    Web开发使用 Controller 基本上可以完成大部分需求,但是我们还可能会用到 Servlet.Filter.Listener.Interceptor 等等. 当使用Spring-Boot时,嵌 ...