总体情况
这次手速够快:ABC in 10min,ABCDE in 30min。
A - Raise Both Hands
思路
分类讨论很简单的。
注意一定要判断 \(0,0\) 这种情况。
Code
// Problem: A - Raise Both Hands
// Contest: AtCoder - Toyota Programming Contest 2024#9(AtCoder Beginner Contest 370)
// URL: https://atcoder.jp/contests/abc370/tasks/abc370_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
//#define int long long
namespace gtx{
// Fast IO
void read(int &x){
x = 0;int h = 1;char tmp;
do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));
while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();
x*=h;
}
void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}
void write(char x){putchar(x);}
void write(int x){
if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;
do{st[++tot]=x%10,x/=10;} while(x);
while(tot){putchar(st[tot--]+'0');};
}
void write(int x,char y){write(x);write(y);}
signed main(){
int a,b;
cin >> a>>b;
cout << (a&&b?"Invalid":(a?"Yes":(b?"No":"Invalid")));
return 0;
}
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T = 1;
// gtx::read(T);
while(T--) gtx::main();
return 0;
}
B - Binary Alchemy
思路
这个直接模拟。
Code
// Problem: B - Binary Alchemy
// Contest: AtCoder - Toyota Programming Contest 2024#9(AtCoder Beginner Contest 370)
// URL: https://atcoder.jp/contests/abc370/tasks/abc370_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
//#define int long long
namespace gtx{
// Fast IO
void read(int &x){
x = 0;int h = 1;char tmp;
do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));
while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();
x*=h;
}
void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}
void write(char x){putchar(x);}
void write(int x){
if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;
do{st[++tot]=x%10,x/=10;} while(x);
while(tot){putchar(st[tot--]+'0');};
}
void write(int x,char y){write(x);write(y);}
const int MAXN =120;
int n,a[MAXN][MAXN];
signed main(){
read(n);
for(int i = 1;i<=n;i++){
for(int j = 1;j<=i;j++) read(a[i][j]);
}
int now = 1;
for(int i = 1;i<=n;i++){
if(now>=i) now = a[now][i];
else now = a[i][now];
}
write(now);
return 0;
}
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T = 1;
// gtx::read(T);
while(T--) gtx::main();
return 0;
}
C - Word Ladder
思路
最小此时明显就是每一个位置上面不一样的位置之和。
于是我们只需要保证字典序最小就行。
考虑怎么做到字典序最小。
- 对于 \(a_i>b_i\) 的操作,它一定会将字典序变小,我们一定要先执行这些操作,并按照 \(i\) 从小到大执行。
- 对于 \(a_i<b_i\) 的操作,它一定会将字典序变大,我们一定要后执行这些操作,并按照 \(i\) 从大到小执行。
Code
// Problem: C - Word Ladder
// Contest: AtCoder - Toyota Programming Contest 2024#9(AtCoder Beginner Contest 370)
// URL: https://atcoder.jp/contests/abc370/tasks/abc370_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
//#define int long long
namespace gtx{
// Fast IO
void read(int &x){
x = 0;int h = 1;char tmp;
do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));
while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();
x*=h;
}
void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}
void write(char x){putchar(x);}
void write(int x){
if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;
do{st[++tot]=x%10,x/=10;} while(x);
while(tot){putchar(st[tot--]+'0');};
}
void write(int x,char y){write(x);write(y);}
string a,b;
vector<int> v1,v2;
signed main(){
cin >> a >>b;
for(int i = 0;i<a.size();i++){
if(a[i]==b[i]) continue;
if(a[i]<b[i]) v2.push_back(i);
else v1.push_back(i);
}
reverse(v2.begin(),v2.end());
cout << v1.size()+v2.size() << endl;
for(int i:v1){
a[i] = b[i];
cout << a << endl;
}
for(int i:v2){
a[i] = b[i];
cout << a << endl;
}
return 0;
}
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T = 1;
// gtx::read(T);
while(T--) gtx::main();
return 0;
}