- 这场做了6题,没有做全场,做了个半场吧,还算可以,最后一题磨了很久。
- A.智乃与瞩目狸猫、幸运水母、月宫龙虾
- 思路分析:是个语法题,单独拿首字母出来全部化成大写然后再判断就可以了。
- code:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define lc p<<1
#define rc p<<1|1
//#define int long long
#define vi vector<int>
#define vpi vector<pair<string,long long>>
#define vvi vector<vector<int>>
typedef long long ll;
typedef pair<long long,long long> PII;
typedef pair<ll,pair<ll,ll>> PIII;
typedef pair<ll,pair<ll,pair<ll,ll>>> pIIII;
const int N = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
void solve() {
string s1,s2;cin >> s1 >> s2;
char a = s1[0],b = s2[0];
a = toupper(a),b = toupper(b);
cout << (a == b ? "Yes\n" : "No\n");
}
signed main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
//system("pause");
return 0;
}
/*
Do smth instead of nothing and stay organized
Don't get stuck on one approach
*/
- B.智乃的数字手串
- 思路分析:我们可以发现,因为首位是相邻的,所以长度为奇数的时候一定不会输,所以如果qcjj是先手的时候并且是奇数的时候一定会获胜。所以判断n的奇偶性就可以了。
- code:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;cin >> t;
while(t--) {
int n;cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
if(n&1) cout << "qcjj\n";
else cout << "zn\n";
}
return 0;
}
- 思路分析:暂时还不会,占个坑。
- code:
点击查看代码
- 思路分析:数据很小,所以只要考虑换一次的情况,直接暴力枚举哪里交换,然后搞一下最大字段和就可以了。
- code:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define lc p<<1
#define rc p<<1|1
//#define int long long
#define vi vector<long long>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,pair<ll,ll>> PIII;
typedef pair<ll,pair<ll,pair<ll,ll>>> pIIII;
const int N = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
void solve() {
int n,k;cin >> n >> k;
vi a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
ll ans = -1e18;
vi b(n + 1);
for(int i = 1; i <= n; i++) {
if(i == 1) b[i] = a[i];
else b[i] = max(b[i - 1] + a[i],a[i]);
//cout << b[i] << "\n";
ans = max(b[i],ans);
}
if(k == 1) {
vi c;
for(int i = 1; i <= n - 1; i++) {
fill(b.begin(),b.end(),0);
c.assign(a.begin(),a.end());
swap(c[i],c[i + 1]);
for(int j = 1; j <= n; j++) {
if(j == 1) b[j] = c[j];
else b[j] = max(c[j],b[j - 1] + c[j]);
ans = max(b[j],ans);
}
}
}
cout << ans << "\n";
}
signed main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
//system("pause");
return 0;
}
/*
Do smth instead of nothing and stay organized
Don't get stuck on one approach
*/
- 思路分析: