栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

【ABC】AtCoder Beginner Contest 261 C++代码

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【ABC】AtCoder Beginner Contest 261 C++代码

A - Intersection
#include
using namespace std;
#define ll long long
const int mo = 1e3;
const int N = 1e5+5;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int kk=max(a,c);
	int tt=min(b,d);
	if(kk 
B - Tournament Result  
#include
using namespace std;
#define ll long long
const int mo = 1e3;
const int N = 1010;
char a[N][N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			int k=a[j][i];
			char gg;
			if(k=='W')gg='L';
			else
			if(k=='L')gg='W';
			else
			gg='D';
			if (a[i][j]!=gg)
			{
				cout<<"incorrect";
				return 0;
			}
		}
	}
	cout<<"correct";
	return 0;
}
C - NewFolder(1)
#include
using namespace std;
#define ll long long
const int mo = 1e3;
const int N = 2e5 + 5;
map mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	string s;
	while (t--)
	{
		cin >> s;
		map ::iterator it= mp.find(s);
		if (it != mp.end())
		{
			mp[s]++;
			cout< 
D - Flipping and Bonus 
#include
using namespace std;
#define ll long long
const int mo = 1e3;
const int N = 5000 + 5;
ll f[N][N], a[N], b[N];
//f[i][j]表示前i个硬币,当前是连续第i次,所能得到的最大价值
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(f,0,sizeof(0));
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int c, y;
	for (int i = 1; i <= m; i++)
	{
		cin >> c >> y;
		b[c] = y;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			f[i][j] = max(f[i - 1][j - 1] + a[i] + b[j], f[i][j]);
			f[i+1][0] = max(f[i][j], f[i+1][0]);
			//cout << i << ' ' << j << ' ' << f[i][j] << endl;
		}
	}
	ll ans = 0;
	for (int j = 1; j <= n; j++)
	{
		ans = max(f[n][j], ans);
	}
	cout << ans;
	return 0;
}
E - Many Operations

输入是一个一个操作输入的,但我们可以全部输入完之后按位处理。最后统一输出

#include
using namespace std;
#define bit(x,i)(((x)>>(i))&1)
int main(){
	int n,c;
	cin >> n >> c;
	vector>op(n);
	for(int i=0;i> op[i].first >> op[i].second;
	vectorans(n);
	for(int k=0;k<30;k++){
		arrayfunc={0,1};
		int crr=bit(c,k);
		for(int i=0;if;
			int x=bit(op[i].second,k);
			if(op[i].first==1)f={0&x,1&x};
			if(op[i].first==2)f={0|x,1|x};
			if(op[i].first==3)f={0^x,1^x};
			func={f[func[0]],f[func[1]]};
			crr=func[crr];
			ans[i]|=crr< 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1026380.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号