A. Reachable Numbers

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 1e9 + ;
int N;
set<int> s; int main() {
scanf("%d", &N);
while(s.find(N) == s.end()) {
s.insert(N);
N += ;
while(N % == ) N /= ;
} printf("%d\n", (int) s.size()); return ;
}

B. Long Number

代码:

#include <bits/stdc++.h>
using namespace std; int N;
string s;
int a[]; int main() {
scanf("%d", &N);
cin >> s;
for(int i = ; i <= ; i ++) {
int x;
scanf("%d", &x);
a[i] = x;
} for(int i = ; i < N; i ++) {
if(a[s[i] - ''] > s[i] - '') {
for(int j = i; j < N; j ++) {
if(a[s[j] - ''] >= s[j] - '')
s[j] = a[s[j] - ''] + '';
else break;
}
break;
}
} cout << s << endl; return ;
}

C1. Increasing Subsequence (easy version)

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]);
string ans = ""; int l = , r = N - , pos = ;
while(l <= r) {
if(a[l] < a[r]) {
if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else break;
} else {
if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else break;
}
} printf("%d\n", ans.length());
cout << ans << endl; return ;
}

C2. Increasing Subsequence (hard version)

代码(在两边一样的情况下只能选左或右跑了):

#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int pos = ;
int a[maxn];
string ans1 = "", ans2 = "", ans = ""; string Left(int st, int en, string s) {
string t = s;
int l = st, r = en;
while(l <= r) {
if(a[l] > pos) {
pos = a[l];
l ++;
t += 'L';
} else break;
}
return t;
} string Right(int st, int en, string s) {
string t = s;
int l = st, r = en;
while(l <= r) {
if(a[r] > pos) {
pos = a[r];
r --;
t += 'R';
} else break;
}
return t;
} int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]); int l = , r = N - ;
int tp = ;
while(l <= r) {
if(a[l] < a[r]) {
if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else break;
} else if(a[l] > a[r]) {
if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else break;
} else {
int poo = pos;
ans1 = ans, ans2 = ans;
ans1 = Left(l, r, ans);
pos = poo;
ans2 = Right(l, r, ans);
if(ans1.length() > ans2.length())
//cout << ans1 << endl;
ans = ans1;
else //cout << ans2 << endl;
ans = ans2;
break;
}
} printf("%d\n", ans.length());
cout <<ans <<endl; return ;
} /* 15
37504 79054 80071 95721 135743 164345 189260 190810 191657 196168 200000 200000 190810 190018 185437 */

E. Minimum Array

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn], c[maxn]; int main() {
multiset<int> s;
scanf("%d", &N);
for(int i = ; i <= N; i ++)
scanf("%d", &a[i]);
for(int i = ; i <= N; i ++) {
int x;
scanf("%d", &x);
s.insert(x);
}
for(int i = ; i <= N; i ++) {
int now = N - a[i] % N;
multiset <int>::iterator it = s.lower_bound(now);
if(it == s.end()) it = s.begin();
c[i] = (a[i] + (*it)) % N;
s.erase(it);
} for(int i = ; i <= N; i ++)
printf("%d%s", c[i], i != N ? " " : "\n"); return ;
}

省赛之后脑子一点都不 丝滑? 暴躁 coder 在线可爱

CodeForces Round #555 Div.3的更多相关文章

  1. 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution

    对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...

  2. Codeforces Round #555 (Div. 3) AB

    A:    http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...

  3. Codeforces Round #555 (Div. 3) E. Minimum Array

    题意:b数组可以自由排序,c[i]=(a[i]+b[i])%n. 题目中要求c数组的字典序是最小的.那么我们需要尽量满足前面的c[i],才能使字典序最小. 我们知道a[i]和b[i]都是[0,n-1] ...

  4. Codeforces Round #555 (Div. 3)[1157]题解

    不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...

  5. Codeforces Round #555 (Div. 3) c2 d e f

    c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...

  6. Codeforces Round #555 (Div. 3) D. N Problems During K Days 【数学思维】

    一 题面 D. N Problems During K Days 二 分析 对于这题,刚开始我就是陷入了对公式的执着,企图用公式直接确定第一个数,然后试着去找序列.经过思考和手动模拟后发现是很难保证正 ...

  7. Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version)【模拟】

    一 题面 C2. Increasing Subsequence (hard version) 二 分析 需要思考清楚再写的一个题目,不能一看题目就上手,容易写错. 分以下几种情况: 1 左右两端数都小 ...

  8. Codeforces Round #555 (Div. 3) E. Minimum Array 【数据结构 + 贪心】

    一 题面 E. Minimum Array 二 分析 注意前提条件:$0 \le  a_{i} \lt n$ 并且 $0 \le  b_{i} \lt n$.那么,我们可以在$a_{i}$中任取一个数 ...

  9. Codeforces Round #555 (Div. 3) A B C1(很水的题目)

    A. Reachable Numbers 题意:设f(x)为 x+1 这个数去掉后缀0的数,现在给出n,问经过无数次这种变换后,最多能得到多少个不同的数. 代码 #include<cstdio& ...

随机推荐

  1. 用ASP.NET Core 2.1 建立规范的 REST API -- 翻页/排序/过滤等

    本文所需的一些预备知识可以看这里: http://www.cnblogs.com/cgzl/p/9010978.html 和 http://www.cnblogs.com/cgzl/p/9019314 ...

  2. Python基础(生成器)

    二.生成器(可以看做是一种数据类型) 描述: 通过列表生成式,我们可以直接创建一个列表.但是,受到内存限制,列表容量肯定是有限的.而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我 ...

  3. redis的list类型!!!!

    list类型 list类型是按照插入顺序排序的字符串链表,可在(left)头部和(right)尾部插入值,效率高. list增操作 若插入时,该键不存在,则会创建.若所有元素被移除,该键也会被删除. ...

  4. python接口自动化(九)--python中字典和json的区别(详解)

    简介 这篇文章的由来是由于上一篇发送post请求的接口时候,参数传字典(dict)和json的缘故,因为python中,json和dict非常类似,都是key-value的形式,为啥还要这么传参,在群 ...

  5. .NET Core微服务之基于Jenkins+Docker实现持续部署(Part 1)

    Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.CI, CD 与Jenkins 互联网软件的开发和发布,已经形成了一套标准流程,最重要的组成部分就是持续集成(Continuous i ...

  6. Solr 16 - 增删改Solr中索引数据的几种方式 (在URL上或Web页面中操作)

    目录 1 添加/更新索引数据 1.1 JSON格式的操作 1.2 XML格式的操作 2 删除索引数据 2.1 删除符合特定条件的数据 2.2 删除指定ID的数据 2.3 删除全部索引数据 3 在doc ...

  7. 一个请求过来都经过了什么?(Thrift版)

    一.背景 最初遇到这个问题是去58面试.部门领导是原同事,所以面试比较水.水到什么程度呢? 面试就是走个形式而已,不会不过的. 一面面试官就问了一个问题:“一个请求过来都经过了什么?”  剩下的全是闲 ...

  8. LindDotNetCore~Ocelot实现微服务网关

    回到目录 网关在硬件里有自己的定义,而在软件架构里也有自己的解释,它就是所有请求的入口,请求打到网关上,经过处理和加工,再返回给客户端,这个处理过程中当然就是网关的核心,也是Ocelot的核心,我们可 ...

  9. axios(封装使用、拦截特定请求、判断所有请求加载完毕)

    博客地址:https://ainyi.com/71 基于 Promise 的 HTTP 请求客户端,可同时在浏览器和 Node.js 中使用 vue2.0之后,就不再对 vue-resource 更新 ...

  10. 【2】Asp.Net Core2.2第一个功能增加

    [前言] 上一篇完成了Asp.Net Core 2.2项目的建立,解释了一番项目结构,这一篇开始动手写个小功能,从Controller-Action-Model-View,完成前后端最基础的交互过程, ...