Codeforces Round 908 (Div. 2)(A~E)(全是思维题)

1894A - Secret Sport 

        题意:A、B在玩博弈游戏。其中一局分为X个小局,赢下Y个大局之后获得最终胜利,结束游戏(X,Y未知)。给定一个只包含字母A和B的序列,分别代表了A获胜和B获胜。问最终胜利者是谁。

        思路:顺着题意来发现由于X,Y都未知,非常难判断谁在一局中赢了。但是逆着想会发现:当有人赢了Y个大局之后游戏直接结束了。因此赢得最后一小局的人也就赢得了游戏。

        

// Problem: A. Secret Sport
// Contest: Codeforces - Codeforces Round 908 (Div. 2)
// URL: https://codeforces.com/contest/1894/problem/0
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
void solve() 
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cntA = 0 , cntB = 0;
	cout<<s[s.size() - 1]<<endl;
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

1894B - Two Out of Three  

        题意:给定一个长度为n的数组a,要求构造长度为n的只包含1 , 2 , 3的数组b,其中必须恰好满足以下三个中的两个条件:

1、\exists i , j (a[i] = a[j],b[i] = 1 , b[j] = 2)

2、\exists i , j (a[i] = a[j],b[i] = 1 , b[j] = 3)

3、\exists i , j (a[i] = a[j],b[i] = 2 , b[j] = 3)

        思路:若有三个数相等,他们下标在b数组上分别为1、2、3,那么将同时满足3个条件,不满足题意。因此对于相等的数而言,只能选其中一个条件进行满足。要求刚好满足两个条件,则至少需要两个不同的数在数组中存在相等的数。让他们分别满足两个条件,其余的数全部置1即可。

        

// Problem: Two Out of Three
// Contest: Codeforces
// URL: https://m1.codeforces.com/contest/1894/problem/B
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
void solve() 
{
	int n;
	cin>>n;
	int a[n];
	for(int i = 0 ; i < n ; i ++)
		cin>>a[i];
	map<int,int>mp;
	int ans[n];
	int flag = 0;
	for(int i = 0 ; i < n ; i ++){
		mp[a[i]]++;
		if(mp[a[i]] == 1){
			ans[i] = 1;
		}
		else if(mp[a[i]] == 2){
			if(flag == 0){
				ans[i] = 2;
				flag ++;
			}
			else if(flag == 1){
				ans[i] = 3;
				flag ++;
			}
			else{
				ans[i] = 1;
			}
		}
		else{
			ans[i] = 1;
		}
	}
	if(flag == 2){
		for(int i = 0 ; i < n ; i ++){
			cout<<ans[i]<<" ";
		}
		cout<<endl;
	}
	else{
		cout<<-1<<endl;
	}
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

 1894C - Anonymous Informant 

        题意:给定一个长度为n的数列b,要求构造出数列a,问是否能够用k次操作将a数组转化成b数组。操作步骤如下:

1、选定a数组中的一个点,要求a_{i} = i

2、将整个数组向左移动 i 位。(a_{1}a_{2}a_{3}a_{4}...a_{i}..a_{n} \rightarrow a_{i + 1}a_{i + 2}...a_{n}...a_{1}a_{2}a_{3}...a_{i}

        思路:同样考虑逆推,由于每次操作选定的a_{i}都会在操作之后变为数组的最后一位,那么b数组的最后一位就是最后一次操作选择的a_{i}。如此不断逆推k次,若期间出现了循环,则一定能够构造出a,使得k次操作后变为b。若期间出现了逆推得到的a_{i} > n的情况,则代表无法选择该数进行操作,则代表操作无法进行,则代表无法构造出a。

        

// Problem: Anonymous Informant
// Contest: Codeforces
// URL: https://m1.codeforces.com/contest/1894/problem/C
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
void solve() 
{
	int n , k;
	cin >> n >> k;
	int a[n];
	for(int i = 0 ; i < n ; i ++){
		cin>>a[i];
	}
	int left = 0;
	int st = n - 1;
	map<int,int>mp;
	mp[0] = 1;
	for(int i = 0 ; i < min(n , k) ; i ++){
		if(a[st - left] > n){
			cout<<"No\n";
			return;
		}
		left += a[st - left];
		left %= n;
		if(mp[left] == 0){
			mp[left]++;
		}
		else{
			cout<<"Yes\n";
			return;
		}
	}
	cout<<"Yes\n";
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

1894D - Neutral Tonality (最水D题)

        题意:给定数组a和b,要求将两个数组合并,其中a数组上数的相对位置无法改变。要求合并后的数组LIS(最长递增子序列)的长度最小。

        思路:直接贪心就行,甚至不用求LIS...要求LIS最小,那么b数组可以从大到小排序。然后考虑合并过程,两数组都从头开始合并,若此时a数组的数大于b数组的数,则将a数组的数放到前面,反之b数组的数放到前面(尽可能保证LIS = 1)。

        

// Problem: Neutral Tonality
// Contest: Codeforces
// URL: https://m1.codeforces.com/contest/1894/problem/D
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
const int INF = 1e9;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
int cmp1(int a , int b){
	return a > b;
}
struct Node{
    int val,num;
}z[maxn]; 
int T[maxn];
int NN;
void solve() 
{
	int n , m;
	cin>>n>>m;
	int a[n] , b[m];
	for(int i = 0 ; i <n ; i ++)
		cin>>a[i];
	for(int i = 0; i < m ; i ++)
		cin>>b[i];
	sort(b ,b + m , cmp1);
	NN = m + n;
	int id = 1;
	for(int l = 0 , r = 0 ; l < n || r < m ;){
		if(l < n && r < m){
			if(a[l] > b[r]){
				z[id].num = id , z[id].val = a[l];
				l++;
			}
			else{
				z[id].num = id , z[id].val = b[r];
				r++;
			}
		}
		else if(l < n){
				z[id].num = id , z[id].val = a[l];
				l++;
		}
		else{
				z[id].num = id , z[id].val = b[r];
				r++;			
		}
		id++;
	}
	for(int i = 1 ; i <= NN ; i ++){
		cout<<z[i].val<<" ";
	}
	cout<<endl;
	for(int i = 0 ; i <= NN ; i ++ ){
		z[i].num = 0 , z[i].val = 0;
	}
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

1894E - Freedom of Choice  

        比赛时差点出来了,还是没想清楚。

        题意:定义一个multiset(多重集合)的价值为集合当中等于集合长度的元素的数量。现你有一个初始空multiset,接下来给定m个multiset,然后给定k , l , r。代表了multiset中有k个不同元素,且必须要选择[L,R]个元素放入到你的multiset中。然后一行给出了每个元素的值,再一行给出了每个元素的个数。求最终你的multiset的价值最小值。

        思路:首先考虑到元素的范围很大,而元素个数比较小,因此可以用离散化处理。求答案的过程可以遍历每个元素,然后计算最少能选多少个该元素。在处理每个元素 x 的过程中,显然不能再遍历每个multiset,于是我们可以将multiset中所有元素分为 x 和 非x两种。那么答案就是看总共选的x个元素当中有多少个非x元素。然后我们发现:由于每个multiset中最少选L个元素,那么就有可能出现必须要选择x元素的情况,因此需要记录一下至少选L个元素的情况下选中了多少个x元素min_x 。如此选完以后剩下的尽可能的不去选择x元素,然后发现:由于每个multiset中最多选择R个元素,因此并不是所有的非x元素都能被选中,因此还需要记录最多选R个元素的情况下有多少个非x元素没被选中 max_{!x}。因此最终选择了       min_x + max(0 ,(x - min_x - (sum - cnt_x - max_{!x})))

        

// Problem: E. Freedom of Choice
// Contest: Codeforces - Codeforces Round 908 (Div. 2)
// URL: https://codeforces.com/contest/1894/problem/E
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
void solve() 
{
	LL l = 0 , r = 0;
	int n;
	cin>>n;
	LL max_cnt = 0;
	unordered_map< LL , LL > mp;
	unordered_map< LL , LL > minn;
	unordered_map< LL , LL > maxx;
	vector<LL>v[n];
	vector<LL>cnt[n];
	LL res_st = 0;
	for(int i = 0 ; i < n ; i ++){
		LL k , ll , rr;
		cin>>k>>ll>>rr;
		l += ll , r += rr;
		for(int j = 0 ; j < k ; j ++){
			LL x;
			cin>>x;
			v[i].pb(x);
		}
		LL cntt = 0;
		for(int j = 0 ; j < k ; j ++){
			LL x;
			cin>>x;
			cntt += x;
			cnt[i].pb(x);
			mp[v[i][j]] += x;
		}
		for(int j = 0 ; j < k ; j ++){
			maxx[v[i][j]] += max(1LL * 0 , cnt[i][j] - max(1LL * 0 ,(rr - (cntt - cnt[i][j]))));//在不可选中的数中有多少个x
			minn[v[i][j]] += max(1LL * 0 , ll - (cntt - cnt[i][j]));//至少选x个是v[i][j]
		}
		res_st += cntt - rr;//共有这么多个数是不可选的
		max_cnt += cntt;//共有max_cnt个数
	}	
	LL ans = 2e18;
	LL num_cnt = 0;
	for(auto it : mp){
		LL x = it.first;//选x个数
		if(x >= l && x <= r)//若不包含了[L , R]之内的所有数,答案可以为0
			num_cnt++;
		else
			continue;
		LL cntt = minn[x];//至少这么多个
		LL res = x - cntt ;//还需要这么多(全部拿其他数/拿完了再拿x)
		LL res_car = max_cnt - mp[x] - res_st + maxx[x];//最多能选这么多个不是x的数
		cntt += max(1LL * 0 , res - res_car);
		ans = min(ans , min(mp[x] , cntt));
	}
	if(r - l >= num_cnt){
		cout<<0<<endl;
	}
	else
		cout<<ans<<endl;
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

        

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: neutral lut是一种中立色调查找表(LUT),用于图像和视频编辑中的色彩校正和调整。LUT是一张表格,其中包含了输入颜色和输出颜色之间的映射关系。neutral lut是一种特定的LUT,其目的是使图像或视频呈现中性的颜色效果。 中性颜色指的是没有明显的色彩偏向,如灰色、白色、黑色等。neutral lut可以帮助去除图像或视频中的色彩偏差,使其更加中性和真实。通过应用neutral lut,可以实现色彩的校正和平衡,使原本有色偏的图像或视频达到较为准确和自然的色彩表现。 中立色调查找表在许多领域都有广泛的应用,如摄影、电影制作、广告设计等。在摄影中,摄影师可以使用neutral lut来调整照片的色温和饱和度,以达到所需的视觉效果。在电影制作中,后期制作团队可以使用neutral lut来统一不同镜头的色彩表现,保持故事情节的连贯性和一致性。 总之,neutral lut是一种通过颜色映射表实现色彩校正和调整的工具。它能够帮助去除色彩偏差,使图像和视频呈现中性的颜色效果。在不同领域的图像和视频编辑中,neutral lut都发挥着重要的作用,提高了表现力和视觉效果。 ### 回答2: "Neutral lut" 是一个短语或术语,但没有提供足够的背景信息来理解其确切含义。以下是关于可能的理解的300字回答。 如果"neutral lut"指的是色彩校正领域的术语,"lut"代表"查找表",那么"neutral lut"可能指的是一种用于校正图像或视频的查找表,以使其显示中性色调。 查找表是一种将输入值映射为输出值的表格或函数。在色彩校正中,查找表被用于调整色彩、亮度和对比度等方面,以改善图像或视频的视觉质量。中性色调通常指的是不带有明显色彩偏差的图像或视频,即灰度图像。 通过使用中性查找表,可以校正图像或视频中可能存在的色彩偏差,例如色偏或色温问。这种校正使得图像或视频中的灰度部分更加中性,即更接近真实的灰度值。 中性查找表在摄影、电影制作和图像后期处理等领域中广泛应用。它们可以通过使用色彩校正软件或硬件设备来应用,通过将输入的色彩信息映射到经过校正的输出色彩,以改善图像或视频的质量和一致性。 总之,"neutral lut"是一个在色彩校正领域中的术语,指的是一种用于校正图像或视频的查找表,以使其显示中性色调。这种校正可以通过应用色彩校正软件或硬件来实现,以改善图像或视频的质量和一致性。 ### 回答3: neutral lut是一种用于图像处理的LUT(Look-Up Table)中的一种。LUT是一种将输入值映射到输出值的查找表。而neutral lut是一种在图像处理中用于实现色彩校准和图像中性化的LUT。 在摄影和电影制作中,色彩校准是非常重要的,它可以确保图像的色彩准确和一致。在这个过程中,使用neutral lut可以使图像的颜色变得中性,即不带有任何色调偏差,使图像呈现自然、真实的色彩表现。 通过使用neutral lut,可以将图像的色调进行调整,使其更加中立。它可以通过查找表来移除或调整图像中的某些色彩偏差,使图像中的颜色更加准确和一致。 同时,neutral lut还可以用于校正拍摄条件不佳或者照片中存在的其他影响的图像。通过应用neutral lut,可以使图像更加具备自然感,更好地还原拍摄场景的真实色彩。 总而言之,neutral lut是一种在图像处理中应用的LUT,它可以用于色彩校准和图像的中性化处理。通过使用neutral lut,可以使图像的色彩更加准确和自然,让观看者能够真实地感受到照片或者影片所呈现的场景和色彩。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值