Atcoder ABC 190 赛后解题报告
最后 40min 都没搞出来 E 我也是服了。
A - Very Very Primitive Game /
首先理解题意,不是谁先吃完谁赢,而是谁先吃完,谁输。
然后就简单了,注意在 a = b a=b a=b 是要考虑谁是先手,先手必输。
//Don't act like a loser.
//This code is written by huayucaiji
//You can only use the code for studying or finding mistakes
//Or,you'll be punished by Sakyamuni!!!h>
#define int long long
using namespace std;
int read() {
char ch=getchar();
int f=1,x=0;
while(ch<'0'||ch>'9') {
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') {
x=x*10+ch-'0';
ch=getchar();
}
return f*x;
}
int a,b,c;
signed main() {
cin>>a>>b>>c;
if(c==1) {
if(a>=b) {
printf("Takahashi\n");
}
else {
printf("Aoki\n");
}
}
else {
if(a>b) {
printf("Takahashi\n");
}
else {
printf("Aoki\n");
}
}
return 0;
}
B - Magic 3
这个题非常简单,对于每一组魔法,把 X i , Y i X_i,Y_i Xi,Yi 和 S , D S,D S,D 做大小比较即可,注意两者只要有一种不满足条件魔法就失效。
//Don't act like a loser.
//This code is written by huayucaiji
//You can only use the code for studying or finding mistakes
//Or,you'll be punished by Sakyamuni!!!
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read() {
char ch=getchar();
int f=1,x=0;
while(ch<'0'||ch>'9') {
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') {
x=x*10+ch-'0';
ch=getchar();
}
return f*x;
}
const int maxn=1e3+10;
int n,x[maxn],y[maxn],s,d;
signed main() {
bool flag=0;
cin>>n>>s>>d;
for(int i=1;i<=n;i++) {
x[i]=read();
y[i]=read();
if(x[i]<s&&y[i]>d) {
cout<<"Yes\n";//有一组成功即可。
return 0;
}
}
cout<<"No\n";//都不成功输出 NO
return 0;
}
C - Bowls and Dishes
这个题一看 k k k 那么小,直接搜索即可,我们枚举第 i i i 个客人把球放在第 C i C_i Ci 或者 D i D_i Di 个盘子上的时候满足的条件数,总共 2 k 2^k 2k 种情况用搜索来枚举,最后写一个 calc
函数检查有多少条件被满足即可,取最大值。
时间复杂度 O ( 2 k ⋅ m ) O(2^k\cdot m) O(2k⋅m)。
//Don't act like a loser.
//This code is written by huayucaiji
//You can only use the code for studying or finding mistakes
//Or,you'll be punished by Sakyamuni!!!
//#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
//#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
#include<bits/stdc++.h>
using namespace std;
int read() {
char ch=getchar();
int f=1,x=0;
while(ch<'0'||ch>'9') {
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') {
x=x*10+ch-'0';
ch=getchar();
}
return f*x;
}
const int maxn=1e2+10;
int n,m,k,a[maxn],b[maxn],ans,c[maxn],d[maxn],hv[maxn];
//hv 记录第 i 个盘子上有多少个球
int calc() {
int ret=0;
for(int i=1;i<=m;i++) {
if(hv[a[i]]&&hv[b[i]]) {
ret++;//满足条件
}
}
return ret;
}
void dfs(int i) {
if(i==k+1) {
ans=max(ans,calc());
return ;
}
hv[c[i]]++;
dfs(i+1);
hv[c[i]]--;//别忘了回溯
hv[d[i