CF补题:思维题

10 篇文章 0 订阅

1.Codeforces Round 879 (Div. 2)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
void func()
{
	int n;
	cin >> n;
	vector<int>a(n);
	int fu = 0;
	int zh = 0;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0)fu++;
		else zh++;
	}
	if (fu > zh)//-1 -1 -1     -1 -1 -1 1      -1 -1 -1 1 1
	{
		ans = fu - n / 2;//fu一定大于n/2
		fu = n / 2;//操作后fu一定要是偶数
	}
	//如果zh>=fu,ans=0
	if (fu % 2 == 0)
	{
		cout << ans << endl;
	}
	else
	{
		cout << ans + 1 << endl;
	}
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


2.Educational Codeforces Round 150 (Rated for Div. 2)(A) 

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
void func()
{
	int n;
	cin >> n;
	if (n <= 4)
		cout << "Bob" << endl;
	else
		cout << "Alice" << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


3. Codeforces Global Round 23, problem: (B)

Problem - B - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
//a只有0和1
//进行可以将ai加到aj上后把ai删掉(i<j)
//0放到前面1放到后面就可以了,如果a中前面(0的数目)是1不是0的话就进行操作
void func()
{
	int n;
	int ans = 0, count0 = 0, count1 = 0;
	cin >> n;
	vector<int>a;
	for (int j = 0; j < n; j++)
	{
		int x;
		cin >> x;
		a.push_back(x);
		if (x == 0)count0++;
		else count1++;
	}
	for (int i = 0; i < count0; i++)
	{
		if (a[i] != 0)
			ans++;
	}
	cout << ans << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


4.Codeforces Round 878 (Div. 3)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
void func()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	string ans;
	for (int i = 0; i+1 < n; i++)
	{
		char x = s[i];//第一个a
		ans = ans + x;
		while (x != s[i + 1])//不相等则继续找到下一个a
		{
			i++;
		}
		i++;
	}
	cout << ans << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


5.Codeforces Round 877 (Div. 2)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
void func()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (auto& x : a)cin >> x;
	sort(all(a));
	if (a[0] < 0)
		cout << a[0] << endl;
	else
		cout << a[n - 1] << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


6.Codeforces Round 876 (Div. 2)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
void func()
{
	int n, k;
	cin >> n >> k;
	if (k == 1)
	{
		cout << n << endl;
		return;
	}
	int ans = 0;
	if (n % k == 0||n % k == 1)
		ans = n / k + 1;
	else
		ans = n / k + 2;
	cout << ans << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


7.Codeforces Round 875 (Div. 1)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
const int N = 2e5 + 100;
vector<pii>adj[N];
int ans;
void dfs(int node, int par, int pos, int cnt)
{
	for (auto ed : adj[node])
	{
		if (ed.first != par)dfs(ed.first, node, ed.second, cnt + (ed.second < pos));
	}
	ans = max(ans, cnt);
}
void func()
{
	int n;
	cin >> n;
     ans = 0;
	 for (int i = 0; i <= n; i++)adj[i].clear();
	for (int i = 1; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		adj[x].push_back({ y,i });
		adj[y].push_back({ x,i });
	}
	dfs(1, -1, 0, 1);
	cout << ans << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}


8.Codeforces Round 828 (Div. 3)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
void func()
{
	int n;
	string s;
	cin >> n;
	vector<int>a(n);
	for (auto& x : a)cin >> x;
	cin >> s;
	map<int, char>m;
	bool ok = 1;
	for (int i = 0; i < n; i++)
	{
		if (m[a[i]]==0)
		{
			m[a[i]] = s[i];
		}
		else
		{
			if (m[a[i]]==s[i])
				continue;
			else
			{
				ok = 0;
				break;
			}
		}
	}
	if (!ok)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}

9.Codeforces Round 828 (Div. 3)(B)

Problem - B - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
void func()
{
	int n, q;
	cin >> n >> q;
	vector<int>a(n);
	ll sum = 0;
	int d1 = 0;
	int d2 = 0;
	for (auto& x : a)
	{
		cin >> x;
		sum += x;
		if (x % 2 == 0)
			d2++;
		else
			d1++;
	}
	vector<pii>que(q);
	for (auto& x : que)
	{
		cin >> x.first >> x.second;
		if (x.first == 0)
		{
			sum += d2 * x.second;
			//偶数+奇数=奇数;偶数+偶数=偶数
			if (x.second % 2 != 0)
			{
				d1 += d2;
				d2 = 0;
			}
		}
		else
		{
			sum += d1 * x.second;
			//奇数+奇数=偶数;奇数+偶数=奇数
			if (x.second % 2 != 0)
			{
				d2 += d1;
				d1 = 0;
			}
		}
		cout << sum << endl;
	}
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}

10.Educational Codeforces Round 137 (Rated for Div. 2)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
void func()
{
	int n;
	cin >> n;
	vector<int>a(n);//升序
	int vis[10] = { 0 };
	int ans = 0;
	for (auto& x : a)
	{
		cin >> x;
		vis[x] = 1;
	}
	for (int i = 0; i < 10; i++)
	{
		if (vis[i] == 0)
		{
			ans++;
		}
	}
	cout << (ll)6*ans * (ans - 1) / 2 << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}

11.Educational Codeforces Round 137 (Rated for Div. 2)(B)

Problem - B - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
void func()
{
	int n;
	cin >> n;
	cout << 1 << " ";
	for (int i = n; i >= 2; i--)
	{
		cout << i << " ";
	}
	cout << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}

12.Educational Codeforces Round 138 (Rated for Div. 2)(A)

Problem - A - Codeforces

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
void func()
{
	int n, m;
	cin >> n >> m;
	//n*n的棋盘
	//m个棋子,一开始是合法状态
	//只能上下左右移动
	vector<pii>k;
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		k.push_back({ x,y });
	}
	if (m < n)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
int main()
{
	cin.tie(0), cout.tie(0)->sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
	{
		func();
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: CF-Font是一种针对少样本字体生成的技术。常规的字体生成需要大量的数据进行训练,而CF-Font则可以仅仅使用少量样本就能达到字体生成的效果,这使得字体生成过程更为高效。CF-Font使用了一种内容融合的方法,先将输入的文本数据与现有字体的特征进行融合,然后再进行新字体的生成。这种方法可以在不牺牲字体特征的情况下,将多种字体特征进行合并,生成一种全新的字体样式。CF-Font可以用于多个应用场景,比如人机交互、电子商务、广告等等。在人机交互方面,CF-Font可以根据用户的喜好和使用习惯,生成适合用户的字体。在电子商务和广告方面,CF-Font可以根据特定的品牌和市场需求,生成符合品牌风格和广告宣传的字体。总之,CF-Font是一种高效、灵活性强、适用性广泛的少样本字体生成技术。 ### 回答2: CF-Font是一种通过少样本生成字体的新技术。它使用了内容融合和生成式对抗网络(GAN)来生成高质量的字体,且只需要极少的样本。 在过去的字体生成中,通常需要大量样本来作为模板。但是,对于许多较小和中等规模的企业或组织,他们缺乏大量样本的资源和预算。这时候,CF-Font就能很好地满足他们的需求。 CF-Font首先将两种字体材料进行内容融合。这种融合基于两种字体的共同特征,它将每个字形的特征和每个字母的形状转换为另一种字体。接下来,采用生成式对抗网络来生成具有高度差异和丰富细节的字体。 因此,CF-Font具有以下几个优点: 首先,少样本生成字体。采用CF-Font,只需要提供一或两个字体进行内容融合,即可生成具有丰富细节的字体,这将大大减少工作量,并为那些缺少样本的组织提供更好的选择。 其次,高效性和灵活性。CF-Font生成的字体具有高度差异和丰富细节可以适应不同的品牌和文化需求。它是一种通用技术,可以生成各种文字风格和形态。 最后,CF-Font是一种先进的人工智能技术。它使用深度学习技术,并结合了内容融合和生成式对抗网络,使得生成的字体质量更高、更真实、更具创意性。 总而言之,CF-Font是一项非常有前途的技术,它为少样本生成字体提供了一种新的选择,并为企业和组织提供了更灵活和高效的选项。 ### 回答3: CF-Font是一种用于few-shot字体生成的算法,通过少量的示例图像生成新字体。这种技术可以帮助解决字体设计师长时间从头开始设计字体的问,实现快速生成新的字体,提高生产效率。 CF-Font的核心方法是在少量的样本图像上进行联合训练,并使用类似GAN的生成网络生成新的字体。这些新的字体可以很好地与原有的字体相匹配,保持连贯性,并且能够生成几乎任何形状或风格的字形。同时,算法还考虑到了字体在不同应用场景下的使用效果,如展示、阅读等,保证生成的字体满足实际需求。 除了在字体设计领域具有很好的应用前景外,CF-Font还可以在其他领域产生巨大的影响。例如,在广告制作、平面设计、Web设计、游戏开发等方面,都需要大量的字体资源,这种技术可以大大简化字体资源的供给,提高设计效率。此外,这种技术还可以用于解决其他问,例如医学图像进行样式转化,用于人脸生成或者人物场景生成等。 总体来说,CF-Font为字体设计和应用领域提供了一种全新的思路和方法。未来,随着算法的进一步研究和应用,CF-Font将会变得更加智能化、可扩展化和适用性更广泛。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值