当前位置:网站首页>【Codeforces Round #806 (Div. 4)(A~F)】
【Codeforces Round #806 (Div. 4)(A~F)】
2022-07-28 03:15:00 【Romantic dog】
Better reading experience \color{red}{ Better reading experience } Better reading experience
List of articles
A. YES or YES?
The main idea of the topic
- Judge whether it is
yesSequential case insensitive strings - Yes, output
YES, Otherwise outputNO
thought
- Read into violent judgment
Code
#include <bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin >> s;
bool flag = 1;
if(s[0] != 'y' && s[0] != 'Y') flag = 0;
if(s[1] != 'e' && s[1] != 'E') flag = 0;
if(s[2] != 's' && s[2] != 'S') flag = 0;
if(s.size() == 3 && flag) cout << "YES" << endl;
else cout << "NO" << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
B. ICPC Balloons
The main idea of the topic
- common A ∼ Z A \sim Z A∼Z Problem , For the first time, send out two balloons , Then a balloon appears
- Ask how many balloons will be sent out in the competition
thought
vis[i]Whether the mark has ever appeared- Send two if they don't appear , Appeared and sent one
- Traversal string summation
Code
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
typedef long long LL;
bool vis[N];
void solve(){
memset(vis,0,sizeof vis);
int n;
cin >> n;
LL cnt = 0;
while(n--){
char a;
cin >> a;
if(!vis[a]){
cnt += 2;
vis[a] = 1;
}
else cnt ++;
}
cout << cnt << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
C. Cypher
The main idea of the topic
- Each password lock has n n n A wheel , On the wheel 0 ∼ 9 0\sim 9 0∼9
- Give the number of the final position display a i a_i ai, And the i i i Location b i b_i bi operations
- Find the original number
thought
- simulation
ans[i]Store the i i i The final number of bits , useflagThe offset of the storage operation- if
Ubeflag --, converselyflag ++ - about
ans[i], Add its offset and take a positive integer modulus , namelyans[i] = ( ans[i] + flag % 10 + 10 ) % 10It is the original number
Code
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n;
int ans[N];
void solve(){
cin >> n;
for(int i = 1; i <= n; i ++) cin >> ans[i];
for(int i = 1; i <= n; i ++){
int m;
cin >> m;
int flag = 0;
while(m--){
char op;
cin >> op;
if(op == 'D') flag ++;
else flag --;
}
ans[i] = (ans[i] + flag % 10 + 10) % 10;
}
for(int i = 1; i <= n; i ++) cout << ans[i] << " ";
cout << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
D. Double Strings
The main idea of the topic
- Given n n n No longer than 8 8 8 String s s s
- If for s i = s j + s k s_i = s_j + s_k si=sj+sk establish , be s i s_i si Marked as 1 1 1, Otherwise, mark as 0 0 0
thought
- n n n The larger , but s i s_i si Shorter
- about s i s_i si, Construct two at a time s i s_i si String s i ′ , s i ′ ′ s_i',s_i'' si′,si′′, Query the string
- If both strings can be found , Then mark s i s_i si by 1 1 1, Instead of 0 0 0
- utilize
s[N]andset<string> stStore all at the same times[i] - Traverse
s[i], The first string is froms[0]Start , The length is1 <= j <= s[i].size() - 1, The second string is froms[j]Start , The length iss[i].size() - j - utilize
st.count(s)Query strings
Code
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
bool vis[n + 10];
memset(vis,0,sizeof vis);
set<string> st;
string s[n + 1];
for(int i = 0; i < n; i ++){
cin >> s[i];
st.insert(s[i]);
}
for(int i = 0; i < n; i ++){
if(s[i].size() == 1) continue;
for(int j = 1; j <= s[i].size() - 1; j ++){
string s1 = s[i].substr(0,j), s2 = s[i].substr(j,s[i].size() - j);
if(st.count(s1) == 1 && st.count(s2) == 1){
vis[i] = 1;
break;
}
}
}
for(int i = 0; i < n; i ++){
if(vis[i]) cout << 1;
else cout << 0;
}
cout << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
E. Mirror Grid
The main idea of the topic
- Given by 0 0 0 and 1 1 1 Form a square array
- Select the array to the right 90 degree ,180 degree ,270 degree
- Find out how to change the value in the original array , Make the values in the four forms of the array all the same, and change the minimum number of operations
thought
- A position in the original two-dimensional array
mp[i][j]After three rotations , It will appear in three positions in total - namely
mp[j][n + 1 - i]、mp[n + 1 - i][n + 1 - j]、mp[n + 1 - j][i] - Count the value of the original position and the value of these three new positions to become the same minimum number of operations
Code
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char mp[N][N];
bool st[N][N];
void solve()
{
int n;
cin >> n;
memset(st, 0, sizeof st);
for (int i = 1; i <= n; i++) cin >> mp[i] + 1;
int ans = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
if(i == j && n % 2 == 1) continue;
if(!st[i][j]){
int cnt = 0;
if(mp[i][j] == '1') cnt++;
st[i][j] = 1;
if(mp[j][n - i + 1] == '1') cnt++;
st[j][n - i + 1] = 1;
if(mp[n - i + 1][n - j + 1] == '1') cnt++;
st[n - i + 1][n - j + 1] = 1;
if(mp[n - j + 1][i] == '1') cnt++;
st[n - j + 1][i] = 1;
ans += min(cnt, 4 - cnt);
}
}
}
cout << ans << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
F. Yet Another Problem About Pairs Satisfying an Inequality
The main idea of the topic
- For sequence a a a, Find satisfaction a i < i < a j < j , 1 ≤ i , j ≤ n a_i \lt i\lt a_j<j,1\le i,j\le n ai<i<aj<j,1≤i,j≤n Of i , j i,j i,j logarithm
thought
- about a i < i < a j < j , 1 ≤ i , j ≤ n a_i \lt i\lt a_j<j,1\le i,j\le n ai<i<aj<j,1≤i,j≤n
- Must be satisfied with
a[i] < i, takea[i] >= iDeletion of , Do not participate in subsequent matching - Must be satisfied with
i < a[j],{i,j}The logarithm of isiPrevious satisfactiona[i] < iThe number of
- Must be satisfied with
- enumeration
j, Binary search minimum satisfactioni < a[j]The location of , Total quantity plusiAll previous satisfactiona[i] < iThe number of
Code
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
int a[N];
typedef long long LL;
LL cnt;
vector<int> st;
void solve(){
int n;
cin >> n;
st.clear();
cnt = 0;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 1; i <= n; i ++){
if (a[i] >= i) continue;
cnt += (lower_bound(st.begin(), st.end(), a[i]) - st.begin());
st.push_back(i);
}
cout << cnt << endl;
}
int main(){
int _;
cin >> _;
while(_--){
solve();
}
return 0;
}
边栏推荐
- Oracle basicfile lob field space recycling shrink space doubts
- 【Codeforces Round #806 (Div. 4)(A~F)】
- Vscode debug displays multiple columns of data
- Ci/cd from hardware programming to software platform
- ELS keyboard information
- Qt官方示例:Fridge Magnets Example(冰箱贴)
- Data center construction (III): introduction to data center architecture
- NPDP candidates! The exam requirements for July 31 are here!
- Unexpected harvest of epic distributed resources, from basic to advanced are full of dry goods, big guys are strong!
- Kubernetes-----介绍
猜你喜欢

数据湖:数据库数据迁移工具Sqoop

Comprehensive comparative study of image denoising

每日刷题巩固知识

《工程电磁场导论》课后习题附答案

Full of dry goods, hurry in!!! Easy to master functions in C language

嵌入式开发:提示和技巧——用C进行防御性编程的最佳实践

为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?

Why is it that when logging in, you clearly use the account information already in the database, but still display "user does not exist"?

机器人工程是否有红利期

Distributed transaction Senta (I)
随机推荐
clientY vs pageY
Original title of Blue Bridge Cup
JVM 内存布局详解,图文并茂,写得太好了!
Kubernetes-----介绍
clientY vs pageY
Data Lake: each module component
Day 8 of DL
Random forest and integration method learning notes
GAMES101复习:光线追踪(Ray Tracing)
Ci/cd from hardware programming to software platform
NPDP candidates! The exam requirements for July 31 are here!
社恐适合什么工作?能做自媒体吗?
为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
style=“width: ___“ VS width=“___“
QT专题1:实现一个简易计算器
My approval of OA project (meeting inquiry & meeting signature)
Industry insight | is speech recognition really beyond human ears?
WEB安全基础 - - -命令执行漏洞
满满干货赶紧进来!!!轻松掌握C语言中的函数
The test post changes jobs repeatedly, jumping and jumping, and then it disappears