A. A+B?

直接读入字符串然后把下标0和2的数字提取出来就行

// Problem: A. A+B?
// Contest: Codeforces - Codeforces Round #839 (Div. 3)
// URL: https://codeforces.com/contest/1772/problem/A
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define C2(n) (n * (n - 1) >> 1)
#define ll long long
#define ull unsigned long long
#define PII pair<int, int>
#define vint vector<int>
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define eqs 1e-6
// const int mod =
// const int N = void solve()
{string s;cin >> s;int a = s[0] - '0',b = s[2] - '0';cout << a + b<< endl;
}signed main()
{ios::sync_with_stdio(false);cin.tie(0);int t = 1;cin >> t;while(t--)solve();return 0;
}

B. Matrix Rotation

最大值和最小值处在对角线上时即为YES,或者像我这样列举所有情况

// Problem: B. Matrix Rotation
// Contest: Codeforces - Codeforces Round #839 (Div. 3)
// URL: https://codeforces.com/contest/1772/problem/B
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define C2(n) (n * (n - 1) >> 1)
#define ll long long
#define ull unsigned long long
#define PII pair<int, int>
#define vint vector<int>
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define eqs 1e-6
// const int mod =
// const int N = vector<int> get(vector<int> a)
{int k = min({a[0],a[1],a[2],a[3]});vint b = a;if(a[1] == k)b[0] = a[1],b[1] = a[3],b[2] = a[0],b[3] = a[2];else if(a[2] == k)b[0] = a[2],b[1] = a[0],b[2] = a[3],b[3] = a[1];else if(a[3] == k)b[0] = a[3],b[1] = a[2],b[2] = a[1],b[3] = a[0];return b;
}void solve()
{vint a(4);cin >> a[0] >> a[1] >> a[2] >> a[3];a = get(a);if(a[0] < a[1] && a[2] < a[3] && a[0] < a[2] && a[1] < a[3])puts("YES");elseputs("NO");
}signed main()
{ios::sync_with_stdio(false);cin.tie(0);int t = 1;cin >> t;while(t--)solve();return 0;
}

C. Different Differences

先从小到大标记:1、2、4、7……,不足的在从大到小标记

// Problem: C. Different Differences
// Contest: Codeforces - Codeforces Round #839 (Div. 3)
// URL: https://codeforces.com/contest/1772/problem/C
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define C2(n) (n * (n - 1) >> 1)
#define ll long long
#define ull unsigned long long
#define PII pair<int, int>
#define vint vector<int>
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define eqs 1e-6
// const int mod =
// const int N =void solve()
{int n, m;cin >> n >> m;int res = 0;vint a(m + 1, 0),ans;for (int i = 1; i <= m; res++){if (res == n)break;a[i] = true;i += res + 1;}for (int i = m; i; --i){if (res == n)break;if (!a[i]){a[i] = true;res++;}}for(int i = 1;i <= m;++i){if(a[i])cout << i << ' ';}cout << endl;
}signed main()
{ios::sync_with_stdio(false);cin.tie(0);int t = 1;cin >> t;while (t--)solve();return 0;
}

D. Absolute Sorting

我是撒比,这题开始用二分答案来写,卡了一个半小时。正确解法是枚举相邻两位的差来确定取值范围即可

// Problem: D. Absolute Sorting
// Contest: Codeforces - Codeforces Round #839 (Div. 3)
// URL: https://codeforces.com/contest/1772/problem/D
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define C2(n) (n * (n - 1) >> 1)
#define ll long long
#define ull unsigned long long
#define PII pair<int, int>
#define vint vector<int>
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define eqs 1e-6
// const int mod =
// const int N =void solve()
{int n;cin >> n;vint a(n);for (int i = 0; i < n; ++i)cin >> a[i];int l = 0, r = inf;for (int i = 1, c; i < n; ++i){if (a[i - 1] < a[i]){c = (a[i - 1] + a[i]) / 2;r = min(r, c);}else if (a[i - 1] > a[i]){c = (a[i - 1] + a[i] + 1) / 2;l = max(l, c);}}if (l <= r)cout << l << endl;elsecout << -1 << endl;
}signed main()
{ios::sync_with_stdio(false);cin.tie(0);int t = 1;cin >> t;while (t--)solve();return 0;
}

E. Permutation Game

这题的题意有点含糊,其大意是,两个操作,将一个红色染成蓝色, 或者将蓝色的位置之间任意排序。如:

此时可以选择3或者5将其染成蓝色,这里不做演示。也能对已经染成蓝色的进行重新排布,如:

当然也可以选择不操作

上述例子中,后手想要赢的话,只要将3、4、5都染成蓝色, 那么他就可以将这三个数从新排布得到降序的数组;而先手想要赢的话,就要将所有的都染成蓝色, 所以后手赢。

所以这题的重点在于染色上而不是排序上。我们可以将数分为三类,一类是只有先手想要染的(数量为a),第二类是只有后手想要染的(数量为b),第三类是两者都要染的(数量为c)。

所以当

  1. a + c <= b时,先手胜(由于是先手,所以可以取等于)
  2. b + c < a时,后手胜
  3. 平局
// Problem: E. Permutation Game
// Contest: Codeforces - Codeforces Round #839 (Div. 3)
// URL: https://codeforces.com/contest/1772/problem/E
// Memory Limit: 256 MB
// Time Limit: 4000 ms
//
// Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define C2(n) (n * (n - 1) >> 1)
#define ll long long
#define ull unsigned long long
#define PII pair<int, int>
#define vint vector<int>
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define eqs 1e-6
// const int mod =
// const int N = void solve()
{int n;cin >> n;int num[3]{0,0,0};for(int i = 1,j = n,c;i <= n;++i,--j){cin >> c;num[1] += (c != i);num[2] += (c != j);num[0] += (c != i && c != j);}if(num[1] <= num[2] - num[0])puts("First");else if(num[2] < num[1] - num[0])puts("Second");elseputs("Tie");
}signed main()
{ios::sync_with_stdio(false);cin.tie(0);int t = 1;cin >> t;while(t--)solve();return 0;
}

c;
num[1] += (c != i);
num[2] += (c != j);
num[0] += (c != i && c != j);
}
if(num[1] <= num[2] - num[0])
puts(“First”);
else if(num[2] < num[1] - num[0])
puts(“Second”);
else
puts(“Tie”);
}

signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);

int t = 1;
cin >> t;
while(t--)solve();return 0;

}


Codeforces Round #839 (Div. 3)题解相关推荐

  1. Codeforces Round #514 (Div. 2)题解

    Codeforces Round #514 (Div. 2)题解 A 喵,直接模拟. B 枚举所有盖章时的,合法的,左上角的位置.能盖的话就盖一下.最后check一下图案是否相等即可 C 一轮一轮的扔 ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. 【算法题解】Codeforces Round #817 (Div. 4)题解

    文章目录 Codeforces Round #817 (Div. 4)题解 A. Spell Check B. Colourblindness C. Word Game D. Line E. Coun ...

  4. Codeforces Round #747 (Div. 2)题解

    Codeforces Round #747 (Div. 2)题解 (本博客将持续更新以后每场CF div2的题解,喜欢ACM.OI的小伙伴记得点个关注哟) 昨天夜晚刷网络流刷入迷了,渐渐就忘记了我还要 ...

  5. Codeforces Round #839 (Div. 3)

    Problem - G - Codeforces (1)题目大意 一个人想提升下棋的rating,但是他只能一轮一轮来,若是他大于或者等于对战的那个人的rating,他的rating就会加1,那个对战 ...

  6. Codeforces Round #789 (Div. 2)题解

    Codeforces Round #789 (Div. 2)题解 A. Tokitsukaze and All Zero Sequence 原题链接 算法标签 贪心 排序 思路 情况一:数组存在零 → ...

  7. Codeforces Round #748 (Div. 3) 题解 完整A~G

    Codeforces Round #748 (Div. 3) 题解 A. Elections 题意 已知竞选中三个候选人的当前得票数 a , b , c a,b,c a,b,c,现在可以增加任何一个人 ...

  8. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

  9. Codeforces Round #734 (Div. 3) 题解

    Hello大家好,今天给大家带来的是 Codeforces Round #734 (Div. 3) 的全题目讲解. 本文链接:https://www.lanqiao.cn/questions/2040 ...

最新文章

  1. Http协议中Get和Post的浅谈
  2. Python基础(1) - 初识Python
  3. 计算机模拟眼科手术原理,眼科病床的合理安排(计算机模拟实例).pdf
  4. 关于windows10设置环境变量的问题
  5. 四则运算(可怜的二柱子)2
  6. 分布与并行计算—并行计算π(Java)
  7. 四剑客查找字符_linux 四剑客 find 、grep、sed、awk整理
  8. arcobject c++实现检查要素是否为multipart(准确而且快 最主要是real 网上代码有问题)
  9. ping32终端安全管理系统_通过Ping32工单管理功能使用教程
  10. JeeSite 工作流Activiti的应用实例
  11. [蓝桥杯]PREV-12.历届试题_危险系数
  12. 小猫爪:PMSM之FOC控制04-SVPWM
  13. linux默认的系统管理账号是,从Linux到Solaris系统管理---1
  14. 什么是AHP 层次分析法?
  15. 阿里第一轮电话面试面经
  16. 开发历程:网页视频流媒体播放器EasyPlayer.JS开发web H5网页播放H.265视频支持FLV与HLS直播与点播
  17. 永磁同步电机矢量控制(一)——数学模型
  18. 计算机内存条能装几个,4G内存条和2G内存条能不能装到一个电脑上?
  19. c语言中local status6,2016年12月英语六级听力真题及答案:第2套
  20. 带pcb板的c语言实验报告,pcb实验报告.doc

热门文章

  1. 流媒体网络协议 -- HLS
  2. springboot+vue+java服装定制商城系统源码介绍
  3. java-php-python-springboot网上体育用品商城系统计算机毕业设计
  4. 分享一个高效的桌面办公助手
  5. Bluestacks模拟器root图文教程
  6. SpringMVC获取前端传来的json数据的四种方法(前后端json交互总结)
  7. mongodb管理工具下载
  8. Android和java知识点总结
  9. springboot踩坑日记——Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be found
  10. 机器学习-使用决策树DecisionTreeRegressor模型对水果蔬菜价格预测