突然发现五天没记录了,这五天学习完全没有按着正常规划进行,先罗列一下吧。

  • 机器学习视频第一周的全部看完了。
  • 算法导论看了几页。
  • 参加了一次CF。rating只加了20,看来提高实力才是最关键的。
  • C++找到了侯捷老师的视频。
  • 貌似记不得什么了。

    记录一下昨天的CF题解吧。

    题目链接:http://codeforces.com/contest/1088

A题:理论上可以用暴力搜,但是除一之外所有的答案都可以写成"x x",不再写代码解释。

B题:题意为数组中的每一个数每次都减去一个最小的数,并输出这个数。可以先排序,然后下面展示的是O(n)复杂度的算法。

#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005];
int main(){ int n,k;
scanf("%d%d",&n,&k);
for(int i = 0; i < n; i++){
scanf("%d",&a[i]);
}
sort(a,a+n);
int sumsub = 0;
int j = 0;
while(k--){
while(j <n && a[j] <= sumsub) j++;
if(j == n) printf("0\n");
else {
printf("%d\n",a[j]-sumsub);
sumsub = a[j];
}
} return 0;
}

C题:题目提到了两个操作,要求在n+1个操作之内讲数组变为升序。可以转化为前n个操作讲n个数对n+1的余数变为递增,然后最后一步对n+1取模。

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int a[10000];
vector<pair<int,int>> ans;
int main(){
int n ;
scanf("%d",&n);
for(int i = 1; i <= n; i++){
scanf("%d",&a[i]);
}
int cnt = 0;
int sum = 0;
for(int i = n; i >= 1; i--){
if((sum+a[i])%(n+1) == i) continue;
else {
cnt++;
int d = (sum+a[i])%(n+1);
if(i > d) {ans.push_back(make_pair(i,i-d));sum+=i-d;}
else {ans.push_back(make_pair(i,n+1+i-d));sum+=n+1+i-d;}
}
}
cnt++;
printf("%d\n",cnt);
for(int i = 0; i < cnt-1;i++){
printf("1 %d %d\n",ans[i].first,ans[i].second);
}
printf("2 %d %d",n,n+1); return 0;
}

D题思路是对的,但是因为一些原因没有去做,不然可能这次就上蓝了。

#include<iostream>

using namespace std;

int query(int a,int b){
cout << "? "<<a<<" "<<b<<endl;
int res;
cin >> res;
return res;
}
int a = 0,b = 0;
int main(){
bool comp = (query(0,0) == 1);
for(int i = 29; i >= 0; i--){
int p = query(a,b|1<<i);
int q = query(a|1<<i,b);
if(p == 1 && q == -1){
a = a|1<<i;
b = b|1<<i;
}else if( p == -1 && q == 1){
continue;
}else{
if(comp) a = a|1<<i;
else b = b|1<<i;
comp = (p==1);
}
}
cout << "! "<<a<<" "<<b<<endl; return 0;
}

以后每天都记录一下吧

2018-12-5 及 codeforces round 525v2的更多相关文章

  1. 2018.9.20 Educational Codeforces Round 51

    蒟蒻就切了四道水题,然后EF看着可写然而并不会,中间还WA了一次,我太菜了.jpg =.= A.Vasya And Password 一开始看着有点虚没敢立刻写,后来写完第二题发现可以暴力讨论,因为保 ...

  2. Codeforces 1023 A.Single Wildcard Pattern Matching-匹配字符 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A. Single Wildcard Patter ...

  3. Codeforces Round #525 (Div. 2)

    Codeforces Round #525 (Div. 2) 哎,忍不住想吐槽一下,又要准备训练,又要做些无聊的事,弄得我都想退出了. 好好的训练不好么???? 只能做出两道水题,其实C题,感觉做出来 ...

  4. Codeforces Round #523 (Div. 2)

    Codeforces Round #523 (Div. 2) 题目一览表 来源 考察知识点 完成时间 A Coins cf 贪心(签到题) 2018.11.23 B Views Matter cf 思 ...

  5. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  7. Codeforces Round #270 1001

    Codeforces Round #270 1001 A. Design Tutorial: Learn from Math time limit per test 1 second memory l ...

  8. Codeforces Round #223 (Div. 2) A

    A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

随机推荐

  1. selenium学习之元素等待(四)

    --为什么要设置元素等待: 目前大多数web应用程序都是使用AJAX和JavaScript开发,每次加载一个网页,包括静态网页和动态网页,也就是加载各种HTML标签和JS文件.在网页中进行元素定位时, ...

  2. python数据结构树和二叉树简介

    一.树的定义 树形结构是一类重要的非线性结构.树形结构是结点之间有分支,并具有层次关系的结构.它非常类似于自然界中的树.树的递归定义:树(Tree)是n(n≥0)个结点的有限集T,T为空时称为空树,否 ...

  3. opencv的imread函数相对路径问题和 main 参数问题

    参考: https://blog.csdn.net/u013404374/article/details/80178822 https://blog.csdn.net/fujilove/article ...

  4. Android Studio3.5在编译项目出现连接不上gradle该怎么办?

    ------------恢复内容开始------------ 报错原因: Could not get resource 'https://dl.google.com/dl/android/maven2 ...

  5. 3-kubernetes监控与日志管理

    监控集群资源利用率 metrics-server是一个集群范围的资源使用情况的数据聚合器,作为一个应用部署在集群中 metrics-server从每个节点上kubelet API收集指标,通过kube ...

  6. Xnip Mac上方便好用的截图工具

    Xnip Mac上方便好用的截图工具 标注 Xnip 拥有齐全的标注功能,您可以对截取的图片进行标注,在标注的同时还能重新调整截图大小. 查看标注操作 GIF 滚动截图 Xnip 的滚动截图功能可以让 ...

  7. Python 中 pip 工具的安装与使用

    pip 是 Python 包管理工具,该工具提供了对Python 包的查找.下载.安装.卸载的功能. 目前如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具. Python 2 ...

  8. SQL Server查询优化指南

    1.尽量不要使用is null,否则将导致引擎放弃使用索引而进行全表扫描.2.char是固定长度,速度快,但占空间,varchar不固定长度,不占空间,但速度慢.3.能使用数字类型就不要使用字符,查询 ...

  9. Go语言中的常见的几个坑

    目录 1.for range 2.defer与闭包 3.map内存溢出 4.协程泄漏 5.http手动关闭 记录一下日常中遇到的几个坑,加深一下印象. 1.for range 这个是比较常见的问题了, ...

  10. Redis哨兵知识点总结

    1.Redis哨兵介绍 sentinal,中文名是哨兵 A.哨兵是redis集群架构中非常重要的一个组件,主要功能如下 集群监控,负责监控redis master和slave进程是否正常工作 消息通知 ...