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