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. 机器学习算法GBDT的面试要点总结-上篇

    1.简介 gbdt全称梯度下降树,在传统机器学习算法里面是对真实分布拟合的最好的几种算法之一,在前几年深度学习还没有大行其道之前,gbdt在各种竞赛是大放异彩.原因大概有几个,一是效果确实挺不错.二是 ...

  2. 使用Visual Studio Code开发.NET Core看这篇就够了

    作者:依乐祝 原文地址:https://www.cnblogs.com/yilezhu/p/9926078.html 在本文中,我将带着大家一步一步的通过图文的形式来演示如何在Visual Studi ...

  3. ASP.NET Core中使用GraphQL - 第二章 中间件

    前文:ASP.NET Core中使用GraphQL - 第一章 Hello World 中间件 如果你熟悉ASP.NET Core的中间件,你可能会注意到之前的博客中我们已经使用了一个中间件, app ...

  4. LitepalNewDemo【开源数据库ORM框架-LitePal2.0.0版本的使用】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 本Demo使用的是LitePal2.0.0版本,对于旧项目如何升级到2.0.0版本,请阅读<赶快使用LitePal 2.0版本 ...

  5. TabTopAutoLayout【自定义顶部选项卡区域(带下划线)(动态选项卡数据且可滑动)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线且可滑动效果.[实际情况中建议使用RecyclerView] 备注:如果 ...

  6. SmartSql 快速使用指南

    SmartSql 快速使用指南(https://github.com/Ahoo-Wang/SmartSql) ISmartSqlMapper 常用(部分)接口概述 函数 说明 Execute IDbC ...

  7. 你觉得 .NET 性能低,可能只是因为你的能力低

    by Conmajia 本文由以下大佬赞助 加入赞助者行列 {{ sponsor.name }} 感恩,你们的赞助让我在抓耳挠腮写文章时不至于断了香烟. var s = [{ name: '◎梦想起航 ...

  8. footer固定在页面底部的实现方法总结

    方法一:footer高度固定+绝对定位 HTML代码: <body> <header>头部</header> <main>中间内容</main&g ...

  9. Activity、Window、View三者之间的联系

    Activity类:Android四大组件之一,是开发者最常用的一个组件 Window类:是一个抽象类,具有窗口管理的功能,实现类为PhoneWindow View类:提供对View的操作,包括绘制测 ...

  10. Linux下载_Linux系统各种版本ISO镜像下载(redhat,centos,oracle,ubuntu,openSUSE)

    以下是风哥收集的Linux系统各种版本ISO镜像下载,包括redhat,centos,oracle,ubuntu等linux操作系统. Linux下载1:红帽RedHat Linux(RHEL5.RH ...