Atcoder ABC 190 赛后解题报告

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(2km)

//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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值