不会有人div4的A还wa几发吧,那个人不会是我吧

Problem - A - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
string a[] = {"Timur", "miurT", "Trumi", "mriTu"};
void Solve() {int n;string s;cin >> n >> s;map<char, int> mp;mp['T'] = 1;mp['i'] = 1;mp['m'] = 1;mp['u'] = 1;mp['r'] = 1;if (n != 5) {cout << "NO\n";return;}for (int i = 0; i < n; i++) {if (mp[s[i]] == 0) {cout << "NO\n";return;} else if (mp[s[i]] == 2) {cout << "NO\n";return;} else {mp[s[i]] = 2;}}cout << "YES\n";
}
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - B - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void Solve() {int n;cin >> n;string s1, s2;cin >> s1 >> s2;for (int i = 0; i < n; i++) {if (s1[i] != s2[i] and (s1[i] == 'R' or s2[i] == 'R')) {cout << "NO\n";return;            }}cout << "YES\n";
}
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - C - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
struct node {int cnt;bool ok1, ok2, ok3;
};
void Solve() {int n;cin >> n;map<string, node> mp;vector<int> a(3);for (int i = 0; i < 3; i++) {for (int j = 0; j < n; j++) {string s;cin >> s;mp[s].cnt++;if (i == 0) {mp[s].ok1 = true;} else if (i == 1) {mp[s].ok2 = true;} else {mp[s].ok3 = true;}}}for (auto it : mp) {if (it.second.cnt == 1) {if (it.second.ok1) {a[0] += 3;} else if (it.second.ok2) {a[1] += 3;} else {a[2] += 3;}} else if (it.second.cnt == 2) {if (it.second.ok1) {a[0]++;}if (it.second.ok2) {a[1]++;}if (it.second.ok3) {a[2]++;}}}for (int i = 0; i < 3; i++) {cout << a[i] << " \n"[i == 2];}
}
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - D - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void Solve() {int n;string s;cin >> n >> s;int mid = n / 2;int cnt = 0;LL ans = 0;vector<pair<int, int>> a;if (n & 1) {for (int i = 0; i < mid; i++) {if (s[i] == 'L') {cnt++;ans += i;a.push_back(make_pair(n - i - 1, i));} else {ans += n - i - 1;}}for (int i = mid + 1; i < n; i++) {if (s[i] == 'R') {cnt++;ans += n - i - 1;a.push_back(make_pair(i, i));} else {ans += i;}}ans += mid;sort(a.begin(), a.end(), [&](pair<int, int> x, pair<int, int> y) {return x.first > y.first;});for (int i = 0; i < cnt; i++) {ans += a[i].first;if (a[i].second < mid) {ans -= a[i].second;} else {ans -= n - a[i].second - 1;}cout << ans << ' ';}for (int i = cnt; i < n; i++) {cout << ans << ' ';}cout << '\n';} else {for (int i = 0; i < mid; i++) {if (s[i] == 'L') {cnt++;ans += i;a.push_back(make_pair(n - i - 1, i));} else {ans += n - i - 1;}}for (int i = mid; i < n; i++) {if (s[i] == 'R') {cnt++;ans += n - i - 1;a.push_back(make_pair(i, i));} else {ans += i;}}sort(a.begin(), a.end(), [&](pair<int, int> x, pair<int, int> y) {return x.first > y.first;});for (int i = 0; i < cnt; i++) {ans += a[i].first;if (a[i].second < mid) {ans -= a[i].second;} else {ans -= n - a[i].second - 1;}cout << ans << ' ';}for (int i = cnt; i < n; i++) {cout << ans << ' ';}cout << '\n';}
}
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - E - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL a[1010][1010];
void Solve() {int n, q;cin >> n >> q;memset(a, 0, sizeof(a));for (int i = 0; i < n; i++) {LL x, y;cin >> x >> y;a[x][y] += x * y;}for (int i = 1; i <= 1000; i++) {for (int j = 1; j <= 1000; j++) {a[i][j] = a[i][j] + a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];}}for (int o = 0; o < q; o++) {int hs, ws, hb, wb;cin >> hs >> ws >> hb >> wb;cout << a[hb - 1][wb - 1] - a[hb - 1][ws] - a[hs][wb - 1] + a[hs][ws] << '\n';}
}
int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - F - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void Solve() {int n, m;cin >> n >> m;vector<string> a(n);const vector<int> dirx = {1, -1, 0, 0, 1, -1, 1, -1};const vector<int> diry = {0, 0, 1, -1, 1, 1, -1, -1};for (int i = 0; i < n; i++) {cin >> a[i];}function<bool(int, int)> check = [&](int x, int y) {if (x < 0 or x >= n or y < 0 or y >= m) {return false;}return true;};for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (a[i][j] == '*') {int cnt = 1;queue<pair<int, int>> qu;qu.push(make_pair(i, j));for (int k = 0; k < 8; k++) {int nx = i + dirx[k], ny = j + diry[k];if (check(nx, ny)) {if (a[nx][ny] == '*') {cnt++;qu.push(make_pair(nx, ny));}}}if (cnt != 3) {cout << "NO\n";return;} else {pair<int, int> x1, x2, x3;x1 = qu.front();qu.pop();x2 = qu.front();qu.pop();x3 = qu.front();qu.pop();if ((x1.first == x2.first and x1.first == x3.first) or (x1.second == x2.second and x1.second == x3.second)) {cout << "NO\n";return;} else if ((abs(x1.first - x2.first + x1.second - x2.second) == 1 and abs(x1.first - x3.first + x1.second - x3.second) == 1) or (abs(x2.first - x1.first + x2.second - x1.second) == 1 and abs(x2.first - x3.first + x2.second - x3.second) == 1) or (abs(x3.first - x1.first + x3.second - x1.second) == 1 and abs(x3.first - x2.first + x3.second - x2.second) == 1)) {int sum = 1;for (int k = 0; k < 8; k++) {int nx = x1.first + dirx[k], ny = x1.second + diry[k];if (check(nx, ny)) {if (a[nx][ny] == '*') {sum++;}}}if (sum != 3) {cout << "NO\n";return;}sum = 1;for (int k = 0; k < 8; k++) {int nx = x2.first + dirx[k], ny = x2.second + diry[k];if (check(nx, ny)) {if (a[nx][ny] == '*') {sum++;}}}if (sum != 3) {cout << "NO\n";return;}sum = 1;for (int k = 0; k < 8; k++) {int nx = x3.first + dirx[k], ny = x3.second + diry[k];if (check(nx, ny)) {if (a[nx][ny] == '*') {sum++;}}}if (sum != 3) {cout << "NO\n";return;}a[x1.first][x1.second] = '.';a[x2.first][x2.second] = '.';a[x3.first][x3.second] = '.';} else {cout << "NO\n";return;}}}}}cout << "YES\n";
}
int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Problem - G - Codeforces

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void Solve() {int n;cin >> n;LL c = (1ll << 31 - 1);int l = 0, r = 0;for (int i = 0; i < n - 2; i++) {if (i % 2 == 0) {l ^= i;} else {r ^= i;}}if ((l ^ c) == (r ^ c)) {l = 0, r = 0;for (int i = 0; i < n - 2; i++) {if (i % 2 == 0) {l ^= (i + 1);} else {r ^= (i + 1);}cout << i + 1 << " ";}if ((n - 2) % 2 == 0) {cout << (l ^ c) << " " << (r ^ c) << "\n";} else {cout << (r ^ c) << " " << (l ^ c) << "\n";}} else {for (int i = 0; i < n - 2; i++) {cout << i << " ";}if ((n - 2) % 2 == 0) {cout << (l ^ c) << " " << (r ^ c) << "\n";} else {cout << (r ^ c) << " " << (l ^ c) << "\n";}}
}
int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;for (int i = 0; i < T; i++) {Solve();}return 0;
}

Codeforces Round #817 (Div. 4)(7/7)相关推荐

  1. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  2. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

  3. Codeforces Round #698 (Div. 2)(A ~ F)6题全,超高质量题解)【每日亿题】2021/2/4

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #698 (Div. 2)(A ~ F)6题全,超 ...

  4. Codeforces Round #808 (Div. 1)(A~C)

    Codeforces Round #808 (Div. 1)(A~C) A:Doremy's IQ 题目大意 给你一个序列,然后你从左到右可以选择弄或者不弄. 然后你有一个智商值,如果你当前弄的数小于 ...

  5. Codeforces Round #699 (Div. 2) (A ~ F)6题全,超高质量良心题解【每日亿题】2021/2/6

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) (A.B.C)[每日亿题]2021/2/ ...

  6. Codeforces Round #739 (Div. 3)(AK实况)

    Codeforces Round #739 (Div. 3) A. Dislike of Threes 找到第kkk个既不是333的倍数,个位数上也不是333的数,也已预处理然后O(1)O(1)O(1 ...

  7. Codeforces Round #703 (Div. 2)(A ~ F)超高质量题解【每日亿题2 / 19】

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A. Shifting Stacks B - Eastern Exhibition C1 - G ...

  8. Codeforces Round #764 (Div. 3)(A~G)

    考试结束rua!开始写题解. 这场打完后明显感觉到自己水平下降了很多,考试结束后该回回手了. 赛中过了A~D,F,E题题目读错了干想了一个多小时.....给整麻了 A. Plus One on the ...

  9. Codeforces Round #827 (Div. 4)(A~G)(F已更新)

    "爷爷,你关注的up主要更新拉!" 今天起开始CF/At不定期更新 A. Sum(暴力) 只需判断a,b,c是否为和关系即可 #include <bits/stdc++.h& ...

最新文章

  1. 谷歌一员工确诊新冠肺炎:已大面积限制员工出行
  2. 调查问卷_员工满意度调查问卷
  3. touchdesigner下载_TouchDesigner Pro Mac版下载_TouchDesigner Pro Mac版官方下载-太平洋下载中心...
  4. C# 计时函数精度测试
  5. 性能测试——美团国内机票网站(Badboy、JMeter)
  6. WebStorm调试Electron
  7. 【转载】ACM中矩阵乘法的应用
  8. 从草根到百万年薪程序员的十年风雨之路,使用指南
  9. Python入门--for循环
  10. [转载] python3文档字符串_python3基础:字符串、文本文件
  11. 元素的水平垂直居中解决方法
  12. matlab图像的读取和保存
  13. U盘无法格式化,变成8M,RAW格式,0字节的U盘修复教程
  14. 同济大学计算机科学系下设几个专业,同济大学计算机科学与技术系简介
  15. 手把手教你Web数据可视化平台搭建
  16. 欧姆龙的PLC的FINS通讯协议的C例子
  17. Centos 7.6 Install shc
  18. Win7edge浏览器看视频黑屏怎么解决?
  19. 【支付宝】支付 系统繁忙,请稍后再试(ALIN10146)
  20. 模拟集成电路笔记 | 第三部分 | Chapter 5-6

热门文章

  1. js锁定表头和列,实现类似execl锁定效果
  2. 原型图、交互设计、UI图,到底啥关系
  3. 2020最新Java通用后台管理系统
  4. 详解C语言实现扫雷游戏
  5. JavaSE常识类英语
  6. http-little-toy(一个go编写Http并发测试工具)
  7. Java判断平年闰年
  8. 器件——TCRT5000参数与实际设计应用
  9. 数据库学习之MySQL (九)—— 数学函数 字符串函数 CONCAT TRIM PAD
  10. 机器学习_深度学习毕设题目汇总——肺结节