Codeforces Round #827 (Div. 4)

A

水题

#include<bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;void solve() {int a,b,c;cin>>a>>b>>c;if(a+b==c||a+c==b||b+c==a)cout<<"YES"<<endl;else cout<<"NO"<<endl;}
signed main(){int t=1;cin>>t;while (t--) solve();return 0;
}

B

水题

#include<bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;void solve() {int n;cin>>n;vector<int> a(n);for(int i=0;i<n;i++) cin>>a[i];sort(a.begin(),a.end());for(int i=0;i<n-1;i++){if(a[i]==a[i+1]){cout<<"NO"<<endl;return;}}cout<<"YES"<<endl;}
signed main(){int t=1;cin>>t;while (t--) solve();return 0;
}

C

如果有一整行或者一整列为同一个字母,说明肯定是最后一次画的。

#include<bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;char g[20][20];void solve() {for(int i=0;i<8;i++){for(int j=0;j<8;j++){cin>>g[i][j];}}for(int i=0;i<8;i++){int cnt=0;for(int j=0;j<8;j++){if(g[i][j]=='R') cnt++;}if(cnt==8){cout<<"R"<<endl;return;}}for(int i=0;i<8;i++){int cnt=0;for(int j=0;j<8;j++){if(g[j][i]=='B') cnt++;}if(cnt==8){cout<<"B"<<endl;return;}}
}
signed main(){int t=1;cin>>t;while (t--) solve();return 0;
}

D

桶计数,暴力找,两个数互质,gcd为1

#include<bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;void solve() {int n;cin>>n;vector<int> a(n+1);vector<int> pos(1001,-1);for(int i=1;i<=n;i++) {cin>>a[i];pos[a[i]]=i;}int ans=0;int ok=0;for(int i=1;i<=1000;i++){for(int j=1;j<=1000;j++){if(__gcd(i,j)==1&&pos[i]!=-1&&pos[j]!=-1){ans=max(ans,pos[i]+pos[j]);ok=1;}}}if(!ok) cout<<-1<<endl;else cout<<ans<<endl;}
signed main(){int t=1;cin>>t;while (t--) solve();return 0;
}

E

预处理,前缀和,二分

#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;
#define int long long
void solve()
{int n, q;cin >> n >> q;vector<int> a(n);for (int i = 0; i < n; i++)cin >> a[i];vector<int> sum(n);sum[0] = a[0];for (int i = 1; i < n; i++) {sum[i] = sum[i - 1] + a[i];}for (int i = 1; i < n; i++) {a[i] = max(a[i], a[i - 1]);}// for (auto& x : a)//     cout << x << " ";// cout << endl;// for (auto& x : sum)//     cout << x << " ";// cout << endl;while (q--) {int x;cin >> x;int l = 0, r = n - 1;int ans = 0;while (l <= r) {int mid = (l + r) / 2;if (x >= a[mid]) {ans = sum[mid];l = mid + 1;} else {r = mid - 1;}}cout << ans << " ";}cout << endl;
}
signed main()
{int t = 1;cin >> t;while (t--)solve();return 0;
}

F

注意开始的时候S,T字符串都是有一个a的,可以发现如果T字符串存在比a字符大,我们就可以让S的a字符放在第一个,T的大于a的字符放在第一个,这样肯定S<T

如果T全是a没有比a大的,就看S有没有比a大的,如果有,则无法构造。如果没有,S也完全是a字符,则比较a字符的数量。

#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;
#define int ll
void solve()
{int q;cin >> q;int hs = 0, ht = 0, cs = 0, ct = 0;while (q--) {int op, k;string x;cin >> op >> k >> x;if (op == 1) {for (auto& c : x) {if (c > 'a') {hs = 1;} else {cs += k;}}} else {for (auto& c : x) {if (c > 'a') {ht = 1;} else {ct += k;}}}// cout << hs << " " << ht << endl;if (ht) {cout << "YES" << endl;} else if (!hs) {if (cs < ct)cout << "YES" << endl;elsecout << "NO" << endl;} else if (hs) {cout << "NO" << endl;}}
}
signed main()
{int t = 1;cin >> t;while (t--)solve();return 0;
}
/*
s:aabb
t:aaaaa
*/

G

观察可以发现,第一个数肯定是a数组中最大的那个数,那么接下来就找和前面或最大的数,可以遍历一遍没有用过的数,找到最大的那个,由于最多有31位,所以最多遍历31次或的结果就是最大的,遍历31次之后,剩下就可以随便输出了。

#include<bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e6 + 7;
const int mod = 1e9 + 7;void solve() {int n;cin>>n;vector<int> a(n);for(int i=0;i<n;i++) {cin>>a[i];}vector<int> vis(n+1,0);int ans=0;for(int i=0;i<min(31,n);i++){int maxOr=0,idx=-1;for(int j=0;j<n;j++){if(vis[j]) continue;if((a[j]|ans)>maxOr){maxOr=a[j]|ans;idx=j;}}vis[idx]=1;cout<<a[idx]<<" ";ans|=a[idx];}for(int i=0;i<n;i++){if(!vis[i]) cout<<a[i]<<" ";}cout<<endl;
}
signed main(){int t=1;cin>>t;while (t--) solve();return 0;
}

Codeforces Round #827 (Div. 4) 题解记录相关推荐

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

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

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

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

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

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

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

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

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

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

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

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

  7. Codeforces Round #827 (Div. 4) A~G

     比赛链接:Dashboard - Codeforces Round #827 (Div. 4) - Codeforces 目录 A Sum B Increasing C Stripes D. Cop ...

  8. Codeforces Round #827 (Div. 4) E. Scuza

    Codeforces Round #827 (Div. 4) E. Scuza 前缀和 前缀和 前缀和 + 二分 二分 二分 Let's compute the prefix sums of the ...

  9. 10.16打卡 Codeforces Round #827 (Div. 4) A~E

    Dashboard - Codeforces Round #827 (Div. 4) - Codeforces 开摆F和G懒得写 A题 排个序就好了 /* ⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿ ...

最新文章

  1. Linux:WPS不能使用中文输入法
  2. Java AOP研究之@Aspect注解的工作原理
  3. Java 线程池详解及实例代码
  4. PHP代码审计弱类型,[代码审计]php弱类型总结
  5. 使用python进行windows系统UI自动化
  6. 从头配置一台医学影像处理的电脑 Ubuntu20.04
  7. Android进程间通信系列-----------进程间的数据传递载体Parcel
  8. 微信小程序云开发—数据库增删改查
  9. 小镇走出的大厂女程序员,也害怕努力后仍一无所获
  10. python为字体添加上下标
  11. 关于JS的一些面试题
  12. python构建指数平滑预测模型
  13. Hadoop HA集群部署 - A - 详解
  14. 数字城市:智慧水库(泉舟时代)
  15. Codeforces 844A
  16. word里面Ctrl+V不能粘贴解决方法
  17. android图片缓存,直接应用项目中的Android图片缓存技术
  18. vue 项目进行直播视频 vue-video-player
  19. 建筑学计算机快速设计,建筑学专业可能会学的软件,什么样计算机好,设计软件对计算机配置的要求.docx...
  20. 联接新机遇,跨界赢未来,OFweek 2017中国物联网大会圆满落幕

热门文章

  1. 智慧城市运营中心建设方案(SCOC)智慧城市的心脏
  2. 《JAVA》课程教学大纲
  3. 坚果Pro上手,锤子不翻身就因此死亡
  4. 联想k910 android6.0,联想k910刷机教程(刷官方系统固件包)
  5. html 花瓣飘落效果,html全屏花瓣掉落特效
  6. objective-c 动画 花瓣飘落
  7. 《魔鬼经济学》:“魔鬼”的世界
  8. Android http post xml
  9. 工业电气领军企业数字化服务全面升级
  10. Python爬虫利器之PhantomJS的用法