ABC 303
祭奠一次烂掉的ABC。
-
C 怎么WA了?
-
F 怎么T了?
-
F 在 kenkoooo 上的评分怎么这么高?
A
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<"="<<x<<endl
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
string s,t;
cin>>s>>t;
bool f=1;
for (int i=0; i<n; i++){
f&=(s[i]==t[i] || (s[i]=='l'&&t[i]=='1') || (s[i]=='1'&&t[i]=='l') || (s[i]=='o'&&t[i]=='0') || (s[i]=='0'&&t[i]=='o'));
}
if (f){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
return 0;
}
B
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<"="<<x<<endl
using ll = long long;
int n,m;
int a[55][55];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for (int i=0; i<m; i++){
for (int j=0; j<n; j++){
cin>>a[i][j];
}
}
int cnt=0;
for (int i=1; i<=n; i++){
for (int j=i+1; j<=n; j++){
bool f=0;
for (int k=0; k<m; k++){
for (int l=1; l<n; l++){
if (a[k][l-1]==i&&a[k][l]==j || a[k][l-1]==j&&a[k][l]==i){
f=1;
}
}
}
cnt+=f^1;
}
}
cout<<cnt<<endl;
return 0;
}
C
WA,还不会,哈哈哈!
D
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<"="<<x<<endl
using ll = long long;
const int N = 3e5+5;
ll dp[N][2];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll x,y,z;
string s;
cin>>x>>y>>z>>s;
s=" "+s;
memset(dp,0x3f,sizeof dp);
dp[0][0]=0;
for (int i=1; i<s.size(); i++){
if (s[i]=='a'){
dp[i][0]=min({dp[i-1][0]+z+y+z,dp[i-1][0]+x,dp[i-1][1]+y+z,dp[i-1][1]+z+x});
dp[i][1]=min({dp[i-1][0]+x+z,dp[i-1][0]+z+y,dp[i-1][1]+y,dp[i-1][1]+z+x+z});
}
else{
dp[i][0]=min({dp[i-1][0]+z+x+z,dp[i-1][0]+y,dp[i-1][1]+x+z,dp[i-1][1]+z+y});
dp[i][1]=min({dp[i-1][1]+x,dp[i-1][1]+z+y+z,dp[i-1][0]+z+x,dp[i-1][0]+y+z});
}
// cout<<dp[i][0]<<","<<dp[i][1]<<endl;
}
cout<<min(dp[s.size()-1][0],dp[s.size()-1][1])<<endl;
return 0;
}
E
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<"="<<x<<endl
using ll = long long;
const int N = 2e5+5;
int n;
int in[N];
vector<int> g[N];
int cen[N],vis[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for (int i=0; i<n-1; i++){
int u,v;
cin>>u>>v;
in[u]++;
in[v]++;
g[u].push_back(v);
g[v].push_back(u);
}
queue<pair<int,int> > q;
for (int i=1; i<=n; i++){
// cout<<in[i]<<endl;
if (in[i]==1){
q.push({i,0});
vis[i]=1;
}
}
while (!q.empty()){
int x=q.front().first,ty=q.front().second;
q.pop();
if (ty==0){
for (auto u : g[x]){
if (!vis[u]){
cen[u]=1;
vis[u]=1;
q.push({u,1});
}
}
}
else if (ty==1){
for (auto u : g[x]){
if (!vis[u]){
vis[u]=1;
q.push({u,2});
}
}
}
else{
for (auto u : g[x]){
in[u]--;
if (!vis[u] && in[u]==1){
vis[u]=1;
q.push({u,0});
}
}
}
}
vector<int> res;
for (int i=1; i<=n; i++){
if (cen[i]){
res.push_back(g[i].size());
}
}
sort(res.begin(),res.end());
for (auto u : res){
cout<<u<<" ";
}
cout<<endl;
return 0;
}
F
WA,还不会,哈哈哈!