首页 > 其他分享 >SYUCT acm第八次限时训练题解

SYUCT acm第八次限时训练题解

时间:2023-01-11 21:22:52浏览次数:70  
标签:code SYUCT int 题解 ++ cin acm -- cout

SYUCT acm第八次限时训练题解

Make it Beautiful

题目大意

code

#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int a[N];
int b[N];
void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];

        b[a[i]]++;
    }
    if (a[1] == a[n])
    {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    sort(a + 1, a + 1 + n);
    cout << a[n] << ' ' << a[1] << ' ';
    for (int i = n - 1; i >= 2; i--)
        cout << a[i] << ' ';
    cout << '\n';
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

Move Brackets

题目大意

题意: 给你一个只有圆括号的字符串,并规定了标准字符串的形式每一个后括号在其前方都能找到和它一对一匹配的前括号。对于给定的字符串,可以选定某些字符将其移动到最前或最后。试问,要将给定字符串变成标准字符串至少需要移动多少个字符?

code

#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int num = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '(')
        {
            num++;
        }
        else
        {
            if (num)
            {
                num--;
            }
        }
    }
    cout << num << '\n';
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

YES or YES?

题目大意

code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        string y;
        cin >> y;
        if (y == "yes" || y == "Yes" || y == "yEs" || y == "yeS" || y == "YEs" || y == "YeS" || y == "yES" || y == "YES")
            cout << "YES" << '\n';
        else
            cout << "NO" << '\n';
    }
    return 0;
}

Cypher

题目大意

code

#include <bits/stdc++.h>
using namespace std;
int y[110];
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        // memset(y, 0, sizeof(y));
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> y[i];
        int k;
        string u;
        for (int j = 1; j <= n; j++)
        {
            cin >> k >> u;
            for (int i = 0; i < k; i++)
            {
                if (u[i] == 'D')
                    ++y[j];
                else
                    --y[j];
                if (y[j] == 10)
                    y[j] = 0;
                if (y[j] == -1)
                    y[j] = 9;
            }
        }
        for (int i = 1; i <= n; i++)
        {
            if (i != n)
                cout << y[i] << " ";
            else
                cout << y[i] << '\n';
        }
    }
    return 0;
}

标签:code,SYUCT,int,题解,++,cin,acm,--,cout
From: https://www.cnblogs.com/x1uc/p/17044875.html

相关文章

  • 【题解】AT3611 Tree MST
    喝,长大了......
  • CF 1581B Diameter of Graph 题解
    题面:给定n个顶点,m条边,任意两点并且最大距离小于k,两个顶点只能连一条边,询问是否能构造出这样的图型思路:1.n=1时进行特判,只有k>1时成立2.m=n(n-1)/2时,是完全图,只有k......
  • 【题解】CF1268C K Integers
    萌新不懂就问,这是什么时代的题啊???思路trick题。首先根据trick可知:先将\([1,k]\)中的数聚在一起再排序是最优的。排序的花费是逆序对数,所以现在的问题是求把\([1,......
  • 又一创新!阿里云 Serverless 调度论文被云计算顶会 ACM SoCC 收录
    关注阿里巴巴中间件公众号,后台回复关键词【FC】查看ACMSoCC录用论文!近日,阿里云函数计算产品团队撰写的关于Serverless调度的创新性论文被ACMSoCC国际会议长文录用......
  • Codeforces 1278 F Cards 增强版 题解 (斯特林数,推式子)
    原题链接增强版链接增强版中k=1e7为啥网上题解的式子都那么长啊.jpg首先令\(p=\frac1m\)。求某个数的次幂的题通常都是无脑转下降幂:\(x^k=\sum_{i=0}^kS_2(k,i)x^{\u......
  • SOJ1711 题解
    题意给定\(n\)个在数轴的区间\([l_1,r_1],[l_2,r_2],...,[l_n,r_n]\)。定义\(I(x)\)为所有包含\([x,x+1]\)的区间形成的集合,即\(I(x)=\{k\mid[x,x+1]\subsete......
  • 搭建k8s集群初始化master节点 kubeadm init 遇到问题解决
    搭建k8s集群时遇到的问题一记,自己找了很久解决方案,也看到有些人提出类似问题后不了了之,于是发出来给网络做一次贡献kubeadminit报错”unknownserviceruntime.v1al......
  • CF850B Arpa and a list of numbers 题解 枚举
    题目链接:https://codeforces.com/problemset/problem/850/B题目大意我们定义一个数列是”坏的数列”当且仅当这个数列不为空且数列中所有元素的最大公约数为\(1\)。......
  • 题解 BZOJ3622【已经没有什么好害怕的了】
    前置知识:二项式反演problem两个\(n\leq2000\)的数组\(A,B\),元素互不相同,求有多少种将\(A,B\)配对的方法使得\(A>B\)的恰好有\(k\)对。题目改过,但是这一步转换......
  • Magic题解
    Magic题解题意简述:给定\(n\)个数\(a_1,a_2,…,a_n\),设对于数\(x\),\(|x|\)表示其在十进制下的位数,也即\(10^{|x|}\lex<10^{|x|+1}\)需要计算:\[\sum_{i=1}^n\sum_{j=i+1......