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

最新文章

  1. 07.GitHub实战系列~7.Git之VS2013团队开发(如果不想了解git命令直接学这篇即可)
  2. sql case when 操作
  3. android国际化(多语言)
  4. Enem 实用方法
  5. AutoLayout +Masonary
  6. Java ArrayList操作
  7. 2013 Asia Chengdu Regional Contest
  8. python数据类型和3个重要函数
  9. Linux查看进程内存占用及内存使用情况
  10. SCU 4436 Easy Math 2015年四川省赛题
  11. ajax异步服务器获取时间
  12. Memory Analyzer Tool 使用手记
  13. 阿里云部署SSL证书详解
  14. mysql6.5 操作日志
  15. pip错误-failed to create process/fatal error in launcher
  16. 音视频处理概要 markdown
  17. mysql5.6版本的优化
  18. ASP.NET项目开发
  19. Cookie禁用了,Session还能用吗?原因详解
  20. inline、block与inline-block

热门文章

  1. Docker系列之入门
  2. LINUX命令行如何查看memcache运行状态
  3. List分组的两种方式
  4. Linux之部署虚拟环境、安装系统
  5. AnimationEvent事件问题
  6. Java反射获取class对象的三种方式,反射创建对象的两种方式
  7. 【ACM】poj_1363_Rails_201308081502
  8. hdu1203--D - I NEED A OFFER!(转化01背包)
  9. 在Linux中samba server的配置
  10. JAVA经常使用数据结构及原理分析