好久没做题了,然后就想着随便做一个。无奈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的更多相关文章

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

  2. [codechef]SnackDown 2017 Online Elimination Round Prefix XOR

    预处理后主席树维护 首先得出最后的答案为 \(\sum_{i=l}^{r}{min(right[i],r)-i+1}\) \(ri[i]\)表示i最远的上升序列(即代码中的f[i]) step1 那么 ...

  3. 2017,科学使用strace神器(附代码,举栗子)

    我感到惊讶,都2017年了,几乎没有人知道他们可以使用strace的了解所有事情.它总是我拔出的第一个调试工具之一,因为它通常在我运行的Linux系统上可用,并且它可以用于解决各种各样的问题. 什么是 ...

  4. spring in action 学习笔记八:用@Primary 或者@Qualifier消除@Autowired引起的歧义现象

    首先解释一下@Primary和@Qualifier这两个注解的意思:@Primary的意思是在众多相同的bean中,优先使用用@Primary注解的bean.而@Qualifier这个注解则指定某个b ...

  5. CI Weekly #10 | 2017 DevOps 趋势预测

    2016 年的最后几个工作日,我们对 flow.ci Android & iOS 项目做了一些优化与修复: iOS 镜像 cocoapods 版本更新: fir iOS上传插件时间问题修复: ...

  6. 猖獗的假新闻:2017年1月1日起iOS的APP必须使用HTTPS

    一.假新闻如此猖獗 刚才一位老同事 打电话问:我们公司还是用的HTTP,马上就到2017年了,提交AppStore会被拒绝,怎么办? 公司里已经有很多人问过这个问题,回答一下: HTTP还是可以正常提 ...

  7. iOS的ATS配置 - 2017年前ATS规定的适配

    苹果规定 从2017年1月1日起,新提交的 app 不允许使用NSAllowsArbitraryLoads来绕过ATS(全称:App Transport Security)的限制. 以前为了能兼容ht ...

  8. 深入研究Visual studio 2017 RC新特性

    在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...

  9. Xamarin+Prism开发详解三:Visual studio 2017 RC初体验

    Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...

随机推荐

  1. nodejs 文件操作模块 fs

    const fs=require("fs"); //文件操作 //创建目录 ./ 代表当前目录 ../ 代表上级目录fs.mkdir('./test',function(err){ ...

  2. 8.2.3 覆写 Equals

    经过对四种不同类型判等方法的讨论,我们不难发现不管是 Equals 静态方法.Equals 虚方法 抑或==操作符的执行结果,都可能受到覆写 Equals 方法的影响.因此研究对象判等就必须将注意 力 ...

  3. hstack()与vstack()函数

    ref: https://blog.csdn.net/csdn15698845876/article/details/73380803 1. hstack()函数 a,b只有一个维度:对第一个维度拼接 ...

  4. 爬虫文件存储-1:mysql

    1.连接并创建数据库 import pymysql db = pymysql.connect(host='localhost', user='root', password='root', port= ...

  5. ORM 事务

    orm 事务: import datetime from appxx import models try: from django.db import transaction with transac ...

  6. Linux - centos7 下 MySQL(mariadb) 和 主从复制

    目录 Linux - centos7 下 MySQL(mariadb) 和 主从复制 MySQL(mariadb) 安装MySQL(mariadb) 配置数据库的中文支持 在远程用 mysql客户端去 ...

  7. qwb VS 去污棒

    qwb VS 去污棒 Time Limit: 2 Sec  Memory Limit: 256 MB Description qwb表白学姐失败后,郁郁寡欢,整天坐在太阳底下赏月.在外人看来,他每天自 ...

  8. hdu_1008_Elevator_201308191629

    ElevatorTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  9. springcloud(十一):服务网关Zuul高级篇

    时间过的很快,写springcloud(十):服务网关zuul初级篇还在半年前,现在已经是2018年了,我们继续探讨Zuul更高级的使用方式. 上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制 ...

  10. Win10中如何把语言栏缩到系统托盘

    Win10中如何把语言栏缩到系统托盘 原来语言栏是在系统托盘中的,右键点击,然后选择“显示语言栏”,就不能缩回去了: 后来在“控制面板\时钟.语言和区域\语言\高级设置”里面,有一个选项: “使用桌面 ...