CF640 div4

草 迟到半个月的补题

真正的懒狗

再懒就无了

  • D. Alice, Bob and Candies

    题意:n个数字,奇数时间从左侧删数字,偶数时间从右侧删数字,每次删的数字之和必须大于上次的。问最多删多少次和左边删除数字和与右边删除数字和。

    题解:很简单的模拟题,初始情况特判即可,不知道当时为什么没做出来

#include<iostream>

using namespace std;
int can[1005];
int main() {
int t;
cin >> t;
while (t--) {
int n;
int a=0, b=0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> can[i];
}
int moves = 0;
int l = 1, r = n,sum=0;
while (l<=r) {
++moves;
if (moves % 2 == 1) {
if (moves == 1) {
sum = can[l++];
a+=sum;
}
else {
int tmp = 0;
while (tmp < sum + 1&&l<=r) {
tmp += can[l++];
}
sum = tmp;
a += sum;
if (l > r) {
break;
}
}
}
else {
int tmp = 0;
while (tmp < sum + 1 && l <= r) {
tmp += can[r--];
}
sum = tmp;
b += sum;
if (l > r) {
break;
}
}
}
cout << moves << " " << a << " " << b << endl; }
}
  • E.Special Elements

    题意:问一组数中有多少个数可以表示成数组的区间和。

    题解:前缀和

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[8010], sum[8010], num[8010];
int main() {
int t;
cin >> t;
while (t--) { int cnt = 0;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
num[a[i]]++;
sum[i] = sum[i - 1] + a[i];
} for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int tmp = sum[j] - sum[i-1];
if (tmp <= n && num[tmp] > 0) {
cnt += num[tmp];
num[tmp] = 0;
}
}
}
memset(num, 0, sizeof(num));
cout << cnt << endl;
}
}
  • F. Binary String Reconstruction

    题意:01串 \(n_0\)代表00个数,\(n_1\)代表\(10或01\)个数,\(n_2\)代表\(11\)个数。t次询问求合法串。

    题解:又是模拟

#include<iostream>
#include<algorithm>
#include<string>
using namespace std; int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
string s1, s2, s3;
cin >> a >> b >> c;
if(a > 0) {
int tmp = a + 1;
while (tmp--) {
s1 += "0";
}
} if (a == 0&&b>0) {
s2 += "0";
}
if (c > 0) {
b--;
}
if (b > 0) {
s2 += "1";
b--;
int cnt = 0;
while (b--) {
if (cnt % 2 == 0)
s2 += "0";
else
s2 += "1";
cnt++;
}
}
if (c > 0) {
int tmp = c + 1;
while (tmp--) {
s3 += "1";
}
}
string res = s3 + s1 + s2;
cout << res << endl;
}
}
  • G. Special Permutation

    题意题解懒得写了,深搜
#include<iostream>
#include<stack>
#include<cstring>
using namespace std;
int ac[6] = { -4,-3,-2,2,3,4 };
int flag = 0;
int vis[1005];
stack<int> s;
int n;
void dfs(int x) {
if (flag == 1) return;
if (s.size() == n) {
while (!s.empty()) {
cout << s.top() << " ";
s.pop();
}
cout << endl;
flag = 1;
return;
} for (int i = 0; i <= 5; ++i) {
int tmp = x + ac[i];
if (tmp <= 0 || tmp > n||vis[tmp]) {
continue;
}
vis[tmp] = 1;
s.push(tmp);
dfs(tmp);
if (flag == 1) return;
vis[tmp] = 0;
s.pop();
} }
int main() {
int t;
cin >> t;
while(t--) {
cin >> n;
for (int i = n; i >0; --i) {
vis[i] = 1;
s.push(i);
dfs(i);
if (flag) {
break;
}
vis[i] = 0;
s.pop();
}
if (flag == 0) {
cout << -1 << endl;
}
flag = 0;
while (!s.empty()) {
s.pop();
}
memset(vis, 0, sizeof(vis));
}
}

现在回头一看都是rz题,为啥当时不敢写呢

CF #640 (div4)的更多相关文章

  1. Codeforces #640 div4 F~G (构造二连弹)

    题意:求一个只由\(01\)组成的字符串,使得它所有长度为\(2\)的子串满足:每对子串的数字和为\(0,1,2\)的个数为\(a,b,c\). 题解:我们先考虑子串数字和为\(1\)的情况,构造出一 ...

  2. [cf]Codeforces Round #784(Div 4)

    由于一次比赛被虐得太惨,,生发开始写blog的想法,于是便有了这篇随笔(找了个近期的cf比赛练练手(bushi))第一次写blog,多多包涵. 第二场cf比赛,第一场打的Div2,被虐太惨,所以第二场 ...

  3. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  6. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  7. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  8. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  9. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

随机推荐

  1. python 03—字符串分割

    字符串分割 例:sentenc = "I am an Englist sentenc" sentence.split() split()把字符串按照空格进行分割,所以得到的结果是 ...

  2. STM32读取匿名光流数据——与Guidance的光流和超声波做对比测试

    使用两个串口同时读取匿名光流和Guidance数据:用以比较两个光流的效果 Github链接:https://github.com/W-yt/YuTian_Pro/tree/master/Guidan ...

  3. RabbitMQ 高级应用

    本文是作者原创,版权归作者所有.若要转载,请注明出处. 本文RabbitMQ版本为rabbitmq-server-3.7.17,erlang为erlang-22.0.7.请各位去官网查看版本匹配和下载 ...

  4. 基于 abp vNext 和 .NET Core 开发博客项目 - 定时任务最佳实战(三)

    上一篇(https://www.cnblogs.com/meowv/p/12974439.html)完成了全网各大平台的热点新闻数据的抓取,本篇继续围绕抓取完成后的操作做一个提醒.当每次抓取完数据后, ...

  5. 爱奇艺|B站|优酷|腾讯视频高清无水印视频下载方法(软件工具教程)

    导读:经常在大型视频网站平台上看到一些很价值和视频,希望能高清无水印下载到本地学习观看,今天小程序定制开发代码哥DaiMaGe6给大家分享一招免费下载全网高清无水印视频的方法. 高清无水印视频下载工具 ...

  6. UML ——区分类图中的几种关系.md

    目录 关联关系 (association): 聚合关系 (aggregation): 合成关系 (composition): 依赖关系 (dependency): 总结: 原文地址 http://ww ...

  7. Java实现 蓝桥杯 算法提高 八数码(BFS)

    试题 算法提高 八数码 问题描述 RXY八数码 输入格式 输入两个33表格 第一个为目标表格 第二个为检索表格 输出格式 输出步数 样例输入 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 ...

  8. (Java实现) 洛谷 P1036 选数

    输入输出格式 输入格式: 键盘输入,格式为: n,k x1,x2,x3-xn 输出格式: 屏幕输出,格式为: 11个整数(满足条件的种数). 输入输出样例 输入样例#1: 4 3 3 7 12 19 ...

  9. Java实现 LeetCode 547 朋友圈(并查集?)

    547. 朋友圈 班上有 N 名学生.其中有些人是朋友,有些则不是.他们的友谊具有是传递性.如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友.所谓的朋友圈,是指 ...

  10. Java实现 LeetCode 453 最小移动次数使数组元素相等

    453. 最小移动次数使数组元素相等 给定一个长度为 n 的非空整数数组,找到让数组所有元素相等的最小移动次数.每次移动可以使 n - 1 个元素增加 1. 示例: 输入: [1,2,3] 输出: 3 ...