7.25暑假集训记录

我真的是吐了....

昨天又打了一场cf,然后直接没有了....

我是菜鸡.....

我排名10000多,队友排名3000多...

好难受....

感觉自己最近打比赛感觉状态好差...打多校还行吧...我已经打了4场十分拉跨的cf了...

感觉是自己心态问题还是实力问题啊....

反正自己就是好菜好菜好菜...

心情不开心,跑来写博客...

没办法啊.正如高中语文老师说的:人生不如意事情十有八九.想的开一些....

不要整天死气沉沉的,我还是喜欢开朗的我啊!!

感觉时间过的好快啊,暑假集训都过了三分之一了..要好好把握时间啊.

今天下午做了3个构造1个1400,2个1500,一个1500的没出来,其他的出来了。。

但是1500的思路是对的,交了好几发都wa了,然后去看样例了....感觉我还是不能看样例啊..不然正式比赛改都改不对啊!!!

但是我感觉自己构造能力还是很强的吧.....(bushi)

总之失败总是贯穿人生始终,这就是人生啊..

状态好的时候直接杀穿...差的时候坐牢(bushi,一直在坐牢...)

先说说昨天晚上的div3吧...感觉还是好菜啊...

BC都wa了好几发...

感觉自己写的代码太麻烦了...太不简化了..

B. Parity Sort:

这题想了一会(30s)就有思路了,就是用结构体定义大小和下标.然后按照大小从小到大排序..

排序之后,如果i位置之前的数组和现在的数组(是a[i].x不是a[a[i].id])同奇偶的话,就可以交换...

然后自己卡了...一直出错0....改了快20分钟....

C. Tiles Comeback

:这题wa了1好几发....

无语死了...

没有考虑a[1]和a[k]相等并且a[1]的个数大于等于k即可....

D:

https://codeforces.com/contest/1851/problem/D

比赛时候感觉自己想的挺对的,但就是这题的细节问题太多了...

然后就一直做不对.然后就看t佬的代码了...30分钟AK...真的...

我想到了前缀和的差分就是原数组...

然后我考虑了缺少的那个在最前面中间和最后面的情况..但就是一直不对啊...

大无语事件..心态有点炸了...

我们用used数组来存差分在1到n并且只出现一次的数

用vector数组来存储差分大于n或者出现多次的数

如果vector数组的size>=2,no

首先考虑在丢掉的数在最前面的情况:

a1一定会入vector..

并且vector只有a1一个数字

然后我们遍历从1到n遍历used数组,如果没用的数字只有2个并且2者之和为n

输出yes,否则输出no

如果在中间也一样:

一定有个数的差分出现了2次.然后我们遍历从1到n遍历used数组,如果没用的数字只有2个并且2者之和为n

如果在最后:vector为空输出yes

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
ll a[200005];
int main(){
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		
		for(int i=1;i<n;i++){
			scanf("%lld",&a[i]);
		}
		
		vector<ll>used(n+5);
		vector<ll>b;
		
		for(int i=1;i<n;i++){
			if(a[i]-a[i-1]>=1&&a[i]-a[i-1]<=n&&used[a[i]-a[i-1]]==0){
				used[a[i]-a[i-1]]=1;
			}else{
				b.push_back(a[i]-a[i-1]);
			}
		}
		
		
		int flag=1;
		if(b.empty()){
			flag=0;
			printf("YES\n");
		}
		if(b.size()>1){
			flag=0;
			printf("NO\n");
		}
		
		vector<ll>left;
		
		if(flag){
			for(int i=1;i<=n;i++){
			if(used[i]==0){
				left.push_back(i); 
			}
		}
	
		
		if(left.size()==2&&b[0]==left[0]+left[1]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		}
		
	
		
	}


	return 0;
}

 

Problem - E - Codeforces

一道树形dp的题目...(被lb误导了)一开始真以为是拓扑排序了...(好像可以拓扑...t神就拓扑做的)

看了样例看了好久啊..

反正就是比较普通的树形dp了..(为啥不是拓扑呢?)因为没用明显的先后出现顺序

并且还可能是双向边!!

很快就写出来了...

看了一看数据感觉是记忆化..

然后最后还是超时了..我就然后又开了一个vis2数组来记录是否遍历过这个点

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
ll dp[200005];
ll c[200005];
int vis[200005];
vector<ll>son[200005];
int vis2[200005]; 
ll dfs(int point){
	
	if(dp[point]||vis[point]==1||vis2[point]==1)return dp[point];
	
	ll sum=0;
	vis2[point]=1;
	for(int i=0;i<son[point].size();i++){
		int j=son[point][i];
		sum=sum+dfs(j);
	}
	
	if(son[point].size()!=0){
		
		dp[point]=min(c[point],sum);
		
	}
	
	return dp[point];
	
}

int main(){
	
	
	scanf("%d",&t);
	
	
	while(t--){
		
		
		int n,k;
		
		
		scanf("%d%d",&n,&k);
		
		
		for(int i=1;i<=n;i++){
			
			dp[i]=0;
			vis[i]=0;
			vis2[i]=0;
			son[i].clear();		
			
		}
	
	
		for(int i=1;i<=n;i++){
			scanf("%lld",&c[i]);
		}
	
		
		for(int i=1;i<=k;i++){
			int x;
			scanf("%d",&x); 
			vis[x]=1;
		}
	
		
		for(int i=1;i<=n;i++){
			int m;
			scanf("%d",&m);
			int x;
			
			for(int j=1;j<=m;j++){
				scanf("%d",&x);
				son[i].push_back(x);
			}
			
			if(vis[i]==1){
				dp[i]=0;
			}	
				
			if(vis[i]==0&&m==0){
				dp[i]=c[i];				
			}
			
			
		}	
		
		for(int i=1;i<=n;i++){
				if(dp[i]!=0||vis[i]==1||vis2[i]==1)continue;
				dfs(i);
				
			}
				
				
			for(int i=1;i<=n;i++){
				
				printf("%lld ",dp[i]);
				
		}
		
		printf("\n");
		
		
	}
	
	return 0;
}

 

Problem - 1421C - Codeforces

一道1400分的构造...感觉还是比较简单的...

但是做了2天晚上..昨天晚上跑路了...前天晚上好像也跑路了哈哈哈

显然如果s是回文全就不需要变了

如果不是回文串的话,s的长度为偶数的话,我们先将其变成偶数

例如字符串s1s2s3s4s5

首先我们得到s2s1s2s3s4s5

然后我得到s2s1s2s3s4s5s4s3s2s1

然后我们得到s2s1s2s3s4s5s4s3s2s1s2即可了代码还是很简单的

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
string s;
int main(){
	cin>>s;
	int n=s.length();
	s=" "+s;
	int flag=1;
	for(int i=1,j=n;i<=n/2;i++,j--){
		if(s[i]!=s[j]){
			flag=0;
			break;
		}
	}
	
	if(flag==1){
		printf("0\n");
		return 0;
	}
	
	int ans=0;
	int f=0;
	if(n%2==0){
		ans++;
		f=1;
		printf("%d\n",ans+3);
		printf("R %d\n",n-1);
		n=n+1;
		
	}
	
	if(f==0){
		printf("3\n");
	}
	
	printf("L %d\n",2);
	printf("R %d\n",2);
	printf("R %d\n",2*n-1);	

	return 0;
}

 

Problem - 1710A - Codeforces

一道涂色题目吧...

我们可以按行也可以按列涂色:(有一个行就可以了)

并且至少要有2个连续的才行!!这是我自己翻译的..其实不是这样的....

但也差不多了

如果我们按行涂色.:

我们计算每种颜料能涂的行数,如果行数大于2,才可以涂色,不然是不可以涂色的(加到tot里面)

而且行为奇数的话.我们必须要有一个大于2的

我们设行数为n

所以只要满足tot>=n&&(lfag||n%2==0)就可以了

flag为是否有一个能涂2行以及之上的

我写的代码异常麻烦...

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
ll a[200005];
int main(){
	scanf("%d",&t);
	while(t--){
		ll n,m,k;
		scanf("%lld%lld%lld",&n,&m,&k);
		ll sum=0;
		for(int i=1;i<=k;i++){
			scanf("%lld",&a[i]);
			sum=sum+a[i];
		}
		
		if(sum<n*m){
			printf("No\n");
			continue;
		}
			
		int flag=0;
		ll now=n;
		int f=0;
		int ans=0;
		for(int i=1;i<=k;i++){
			if(a[i]/m>=n)f=1;
			if(a[i]/m>=2){
				now=now-a[i]/m;
			}	
			if(a[i]/m>=3){
				ans=1;
				if(a[i]/m%2==1)flag=1;
				
			}
			
		}
		
		
		int flag1=0;
		int ans1=0;
		ll cnt=m;
		for(int i=1;i<=k;i++){
			if(a[i]/n>=m)f=1;
			if(a[i]/n>=2){
				cnt=cnt-a[i]/n;
			}	
			if(a[i]/n>=3){
				ans1=1;
				if(a[i]/n%2==1)flag1=1;
				
			}	
		}
		
				
		if((now<=0&&flag&&n%2==1)||(now<0&&ans&&flag==0)||(cnt<0&&ans1&&flag1==0)||(now<=0&&n%2==0)||(cnt<=0&&flag1&&m%2==1)||(cnt<=0&&m%2==0)||f){
			printf("Yes\n");
		}else{
			printf("No\n");
		}	
			
	}
	
	return 0;
}

 

简化代码:

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
ll n,m,k;
ll a[100005]; 
int main(){
	scanf("%d",&t);
	
	while(t--){
		scanf("%lld%lld%lld",&n,&m,&k);
		
		for(int i=1;i<=k;i++){
			scanf("%lld",&a[i]);
		}
		ll tot=0;
		ll flag=0;
		for(int i=1;i<=k;i++){
			if(a[i]/m>2)flag=1;
			if(a[i]/m>=2){
				tot=tot+a[i]/m;
			}
		}
		
		int f=0;
		if(tot>=n&&(flag||n%2==0)){
			printf("Yes\n");
			f=1;	
		}
		
		 tot=0;
		 flag=0;
		for(int i=1;i<=k;i++){
			if(a[i]/n>2)flag=1;
			if(a[i]/n>=2){
				tot=tot+a[i]/n;
			}
		}
		
		if(f==0){
			if(tot>=m&&(flag||m%2==0)){
			printf("Yes\n");
			f=1;
		
		}
		}
		
		if(f==0){
				printf("No\n");	
		}
	
	}


	return 0;
}

 

Problem - 1722G - Codeforces

这题还是很有意思的:想了一个小时左右没想出怎么做...

异或满足交换律...

还有异或和为0的数一定相等

先说说我的思路吧:

因为4和5,6和7异或为1

注意5和6异或不为1’

然后我就想着构造异或为1...

发现只适用于奇偶的对数为偶数对的

奇数对的不适合..又想了一会,就看答案了

注意:

奇数位置异或和偶数位置异或相等,所以整个异或为0

然后我又开始想反过来是否正确..是正确的,因为异或满足分配律

然后我们可以构造前n-2个数字

	#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
int main(){
	scanf("%d",&t);
	while(t--){
		ll case1=0;
		ll case2=0;
		int n;
		scanf("%d",&n);
		for(int i=0;i<n-2;i++){
			case1=case1^i;
			case2=case2^(i+1);
		}
		ll case3=(1ll<<30);
		
		if(case1!=0){
			for(int i=0;i<n-2;i++){
				printf("%d ",i);
			}
			case1=case1^case3;
			cout<<case3<<" "<<case1<<endl; 
		}else{
			for(int i=0;i<n-2;i++){
				printf("%d ",i+1);
			}
			case2=case2^case3;
			cout<<case3<<" "<<case2<<endl; 
		}
	}


	return 0;
}

 

0 1 2 3 ...n-3如果为0的话

我们构造 1 2 3 .. n-2,一定不为0

因为上面1 2 3...n-3的异或一定等于0!!异或为0只有2个数相等

假设n-2异或为case,我们设u=2^30,其实没变要开这么大...其实还是有必要的...

n的范围为200000

第n-1个数为u,第n个数为u^case

真的牛没想出来

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值