SnackDown Online Qualifier 2017
好久没做题了,然后就想着随便做一个。无奈cf都是晚上,然后就看见这个,随便做做。
资格赛,只要做出来1题就行了,4天的时间。
1. 水题
#include <iostream>
#include <stdio.h> using namespace std; int n;
string s;
void yes() {
cout << "Valid" << endl;
}
void no() {
cout << "Invalid" << endl;
}
void solve() {
cin >> n >> s;
int t = ;
for (char c : s) {
if(c == 'H') {
if(t == ) {
t = ;
} else {
no();
return;
}
} else if(c == 'T') {
if(t == ) {
t = ;
} else {
no();
return;
}
}
}
if(t != ) no();
else yes();
} int main() {
//freopen("test.in", "r", stdin);
int _;
cin >> _;
while(_--)
solve();
return ;
}
2. 就是 1, 2,3,。。,3,2,1,必须是奇数个。
#include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e2 + ; int n;
int a[maxn];
void yes() {cout << "yes" << endl;}
void no() {cout << "no" << endl;}
void solve() {
cin >> n;
for (int i = ; i <= n; i++) cin >> a[i];
if(n % == ) {
no(); return;
}
for (int i = ; i <= n / + ; i++) {
if(i != a[i] || a[i] != a[ + n - i]) {
no(); return;
}
}
yes();
} int main() {
// freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
int _;
cin >> _;
while(_--)
solve();
return ;
}
3. 这个题,我写的很麻烦, 上来先判断线段的类型,有三种,点,水平和垂直,然后每2种进行考虑。
只要一个是点, 就判断这个点是不是在另一个线段上。
2条线段类型相同, 都是水平或者垂直, 这个时候, 必须共线才满足条件,否则不满足。
2条线段类型不同,这个时候,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 type, mx, ma, mb;
void work(int x, int y, int a, int b) {
type = mx = mb = -;
if(x == a && y == b) {
type = ;
ma = x; mb = y;
return;
}
if(x == a) {
type = ;
mx = x;
ma = min(y, b);
mb = max(y, b);
} else {
type = ;
mx = y;
ma = min(x, a);
mb = max(x, a);
}
}
void yes() {
cout << "yes" << endl;
}
void no() {
cout << "no" << endl;
}
void solve() {
int x, y, a, b;
cin >> x >> y >> a >> b;
work(x, y, a, b);
int xt = type, xx = mx, xa = ma, xb = mb;
cin >> x >> y >> a >> b;
work(x, y, a, b);
//cout << xt << " " << type << endl;
if(xt == type) {
if(xt == ) {
if(xa == ma && xb == mb) {
yes();
} else {
no();
}
return;
}
if(xx != mx) {
no();
return;
}
if(xa > mb || ma > xb) {
no();
return;
}
yes();
} else {
if(xt == ) {
if((xa == mx && xb >= ma && xb <= mb) || (xb == mx && xa >= ma && xa <= mb)) {
yes(); } else {
no();
}
return;
}
if(type == ) {
if((ma == xx && mb >= xa && mb <= xb) || (mb == xx && ma >= xa && ma <= xb)) {
yes();
} else no();
return;
}
if((xx == ma || xx == mb) && (mx == xa || mx == xb)) {
yes();
return;
}
no();
}
} int main() {
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
int _; cin >> _;
while(_--)
solve();
return ;
}
4. 大蛇吃小蛇,先从小到大排序,然后对于一次查询,大于等于l的都是满足要求的, 这个是二分, 然后判断剩下的最多能凑成几条蛇。
剩下的能凑成几条,也是判断一种状况, 左边的蛇都被吃掉,右边的蛇变长成l,看需要的个数是否是左边的个数, 这个过程也是二分,然后就完了。
#include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + ;
int n, q;
int a[maxn];
ll s[maxn];
ll work(int x, int y) {
return s[y] - s[x - ];
}
void solve() {
memset(a, , sizeof a);
memset(s, , sizeof s);
scanf("%d%d", &n, &q);
for (int i = ; i <= n; i++) {
scanf("%d", &a[i]);
//s[i] = s[i - 1] + a[i];
}
sort(a + , a + n + );
for (int i = ; i <= n; i++)
s[i] = s[i - ] + a[i];
int k;
while(q--) {
scanf("%d", &k);
int t = lower_bound(a + , a + n + , k) - a;
//cout << t <<endl;
int res = n + - t;
int left = , right = t - , ed = t - ;
while(left < right) {
int mid = (left + right) / ;
ll st = 1ll * (ed - mid) * k - work(mid + , ed);
//cout << st << " " << mid << endl;
if(st > mid) {
left = mid + ;
} else right = mid;
//cout << left << " " << right << " " << mid << endl;
}
//cout << left << " " << right << endl;
if(left == right)
res += ed - left;
printf("%d\n", res);
}
} int main() {
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
int _;
scanf("%d", &_);
while(_--)
solve();
return ;
}
SnackDown Online Qualifier 2017的更多相关文章
- Bumped! 2017 ICPC North American Qualifier Contest (分层建图+dijstra)
题目描述 Peter returned from the recently held ACM ICPC World finals only to find that his return flight ...
- [codechef]SnackDown 2017 Online Elimination Round Prefix XOR
预处理后主席树维护 首先得出最后的答案为 \(\sum_{i=l}^{r}{min(right[i],r)-i+1}\) \(ri[i]\)表示i最远的上升序列(即代码中的f[i]) step1 那么 ...
- 2017,科学使用strace神器(附代码,举栗子)
我感到惊讶,都2017年了,几乎没有人知道他们可以使用strace的了解所有事情.它总是我拔出的第一个调试工具之一,因为它通常在我运行的Linux系统上可用,并且它可以用于解决各种各样的问题. 什么是 ...
- spring in action 学习笔记八:用@Primary 或者@Qualifier消除@Autowired引起的歧义现象
首先解释一下@Primary和@Qualifier这两个注解的意思:@Primary的意思是在众多相同的bean中,优先使用用@Primary注解的bean.而@Qualifier这个注解则指定某个b ...
- CI Weekly #10 | 2017 DevOps 趋势预测
2016 年的最后几个工作日,我们对 flow.ci Android & iOS 项目做了一些优化与修复: iOS 镜像 cocoapods 版本更新: fir iOS上传插件时间问题修复: ...
- 猖獗的假新闻:2017年1月1日起iOS的APP必须使用HTTPS
一.假新闻如此猖獗 刚才一位老同事 打电话问:我们公司还是用的HTTP,马上就到2017年了,提交AppStore会被拒绝,怎么办? 公司里已经有很多人问过这个问题,回答一下: HTTP还是可以正常提 ...
- iOS的ATS配置 - 2017年前ATS规定的适配
苹果规定 从2017年1月1日起,新提交的 app 不允许使用NSAllowsArbitraryLoads来绕过ATS(全称:App Transport Security)的限制. 以前为了能兼容ht ...
- 深入研究Visual studio 2017 RC新特性
在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...
- Xamarin+Prism开发详解三:Visual studio 2017 RC初体验
Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...
随机推荐
- windows程序设为开机自启动
在Windows文件管理器中输入 %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup 把程序快捷方式放到此处即可.
- ELK6 收集不同来源的日志并做区分
https://blog.csdn.net/u010871982/article/details/79035317 使用filebeat替代logstash进行日志采集 https://blog.cs ...
- 一篇入门Node.js
目录 1.Node.js 简介 2.Node.js NPM 3.Node.js 模块 4.Node.js 事件 5.Node.js Buffer 6.Node.js 文件系统 7.Node.js St ...
- Git 基础教程 之 别名
配置别名, 例如: git config --global alias.st status git config ...
- hdu2011 多项式求和【C++】
多项式求和 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 【codeforces 760D】Travel Card
[题目链接]:http://codeforces.com/contest/760/problem/D [题意] 去旅行,有3种类型的乘车票; 第一种:只能旅行一次20元 第二种:按时间计算,90分钟内 ...
- Network Saboteur POJ 2531 回溯搜索
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12886 Accepted: 6187 Description A un ...
- 洛谷—— P1077 摆花
https://www.luogu.org/problem/show?pid=1077 题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客 ...
- 机器学习4logistic回归
对于线性回归.logistic回归,在以前准备学习深度学习的时候看过一点,当时的数学基础有点薄弱,虽然现在还是有点差,当时看到神经网络之后就看不下去了. 不过这次是通过python对logistic回 ...
- EasyUI 在textbox里面输入数据敲回车后查询和普通在textbox输入数据敲回车的区别
EasyUI实现回车键触发事件 $('#id').textbox('textbox').keydown(function (e) { if (e.keyCode == 13) { alert('ent ...