题解(自记录) | 牛客寒假集训营20250206第四场比赛
A.Tokitsukaze and Absolute Expectation
题目:https://ac.nowcoder.com/acm/contest/95336/A
B.Tokitsukaze and Balance String (easy)
题目:https://ac.nowcoder.com/acm/contest/95336/B
C.Tokitsukaze and Balance String (hard)
题目:https://ac.nowcoder.com/acm/contest/95336/C
D.Tokitsukaze and Concatenate Palindrome
题目:https://ac.nowcoder.com/acm/contest/95336/D
E.Tokitsukaze and Dragon's Breath
题目:https://ac.nowcoder.com/acm/contest/95336/E
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int T;cin >> T;
while(T--){
int n,m;cin >> n >> m;
vector a(n+1,vector<ll>(m+1));
map<int,ll>mp1,mp2;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
int x;
cin >> x;
mp1[i+j]+=x;
mp2[i-j]+=x;
a[i][j]=x;
}
}
ll ans=-2e9;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
auto it=mp1[i+j]+mp2[i-j]-a[i][j];
if(it>ans)ans=it;
}
}
cout << ans <<endl;
}
}
题解思路:观察可得,左上到右下的对角线满足 x + y 都相等,左下到右上的对角线满足 x - y 都相等,所以选择将每条对角线的值之和记录下来然后通过枚举各个格子的对角线总和求出其最大值
F.Tokitsukaze and Kth Problem (easy)
题目:https://ac.nowcoder.com/acm/contest/95336/F
G.Tokitsukaze and Kth Problem (hard)
题目:https://ac.nowcoder.com/acm/contest/95336/G
H.Tokitsukaze and Necklace
题目:https://ac.nowcoder.com/acm/contest/95336/H
I.Tokitsukaze and Pajama Party
题目:https://ac.nowcoder.com/acm/contest/95336/I
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int T;cin >> T;
while(T--){
int n;cin >> n;
string s;cin >> s;
s=s+" ";
int f=0,ans=0;
for(int i=0;i<n;i++){
if(s.substr(i+1,8)=="uwawauwa")ans+=f;
if(s[i]=='u')f++;
}
cout << ans <<endl;
}
}
题解思路:将'u'视为a,"uwawauwa"视为b,由题意需要"u*uwawauwa",其中'*'需要占据至少一个格子,则遍历一遍数组找出每个b,并记录每个b前都有多少个a。
J.Tokitsukaze and Recall
题目:https://ac.nowcoder.com/acm/contest/95336/J
K.Tokitsukaze and Shawarma
题目:https://ac.nowcoder.com/acm/contest/95336/K
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll T;
cin >> T;
while(T--){
ll x,y,z,a,b,c,ma;
cin >> x >> y >> z >> a >> b >> c;
ma=max(x*a,y*b);
ma=max(ma,z*c);
cout << ma << endl;
}
}
题解思路:需要完成三步,沙威玛,可乐和薯条将三者的时间算出来之后取最大值即可求出最少等待时间
L.Tokitsukaze and XOR-Triangle