The second day of labor union

I'm dead

I am a trash

I am a toilet cleaner

I was divided into a class. Although it was expected that I didn't rush into the good class, I didn't expect that the old class was not changed. Go! ! It's outrageous! ! !
However, at the beginning of today, I knocked the window I mentioned last time for a while, changed the version from the day before yesterday, and was a great and holy senior . I also looked at it a few times. The mechanical and courageous Qiu Yu is doing it. I was busy doing housework and sent me a few data that I couldn't make and let me change it myself, but I still couldn't change it. After all, I couldn't rely too much on the senior, so I thought that the method was indeed wrong.

morning

Mainly learned how to generate random numbers, the principle of random numbers, how to run data, and how to beat

Violence creates miracles, keeps safe against shooting

#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
int main()
{
    
    
	for(int T=1;T<=10086;T++)
	{
    
    
		system("");
		
		double st=clock();
		
		system("");
		
		double ed=clock()
		
		system("");
		
		if(system(""))
		{
    
    
			puts("")
			
			return 0;
		}
		
		else 
		{
    
    
			print("Ac,测试点 #%d,用时 %.01fms\n",T,ed-st);
		}
	}
}

That's probably the case for the matchmaking, and the double quotes are the output files of the two codes written.

in the afternoon

Learn the trie, it is to listen to understand, but they also can not write, so I took before owe fruit merge

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
long long a[N],n,sum,len;
int main() 
{
    
    
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)	scanf("%lld",&a[i]); 
	sort(a+1,a+n+1);
	while(len<n)
	{
    
    
		len=1;
		while(a[len]==0)	len++;
		a[len]+=a[len+1];
		sum+=a[len];
		for(int i=len+1;i<n;i++)	a[i]=a[i+1];
		n--;
		for(int i=len;i<n;i++)
			if(a[i]>a[i+1])
				swap(a[i],a[i+1]);
	}
	printf("%lld",sum);
	return 0;
}

The smallest two piles of fruits are added together, but after the addition, it is not the smallest. You have to compare and exchange. It is easy to time out if you sort each time, and you are happy after the code is finished.
So I went back to my new class from the computer room between classes and found that I didn't even have a table. The main reason was that I was too culinary. I had to ask myself if I was worthy in everything. Do I have a table? It is said that they introduced themselves before I came back, and I was separated, so most of them did not know me, which is very pitiful, because not knowing me means that I don’t know to what extent humans can cook. .

So after I came back, I started looking at the Trie tree in the book

Code the first board question The XOR Largest Pair .

#include <bits/stdc++.h>
using namespace std;
long long a[123456],ans,n;
int main()
{
    
    
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)	ans=max(ans,a[i]^a[j]);
	cout<<ans;
	return 0;
}

In the school oj, such enumeration can be violent 80 points, and those who run this data will have a safe life! ! ! Orz,
but you still have to write positive solutions when writing questions

But I'm too culinary, so I wrote my cultural homework for a while

Later, I thought about it, or this thing is based on each digit, if it is different, it becomes 1, and if it is the same, it is 0, so I decided to judge the digit of the largest number, and then use the same digit as this number. Count ^ Other digits are smaller than this, it seems that it can be optimized a lot.

#include <bits/stdc++.h>
using namespace std;
long long weishu,a[123456],xinshuzu[123456],er[123456],ans,len,n;
int main()
{
    
    
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
    
    
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	er[0]=1;
	for(int i=1;i<=33;i++) er[i]=er[i-1]*2;
	for(int i=1;i<=n;i++)
	{
    
    
		if(er[i]>a[n])
		{
    
    
			weishu=i-1;
			break;
		}
		if(er[i]==a[n])
		{
    
    
			weishu=i;
			break;
		}
	}
	for(int i=n;i>=1;i--)
	{
    
    
		if(er[weishu]<=a[i])
		{
    
    
			xinshuzu[++len]=a[i];
			n--;
		}
		else break;
	}
	for(int i=1;i<=n;i++)
	{
    
    
		for(int j=1;j<=len;j++)
		{
    
    
			ans=max(ans,xinshuzu[j]^a[i]);
		}
	}
	cout<<ans;
	return 0;
}

It was done in one go, so I got a high score of 60 points in the school oj, of which 20 points were overtime. It seems that the people who run the data may also think of my speculative method. I got stuck in two groups. It is not as pure violence. .
After listening to the explanation from the myf boss, I understood that I had to save every digit of each number, store it in a two-dimensional array, and then match, if it didn’t work, I would just do it.

#include<bits/stdc++.h>
using namespace std;
const int N=5e6+10;
int x,ans,t[N][32],len=1,n,num;
void insert(int a)
{
    
    
	int p=1;
	for(int k=30;k>=0;k--)
	{
    
    
		num=a>>k&1;
		if(t[p][num]==0)
			t[p][num]=++ len;
		p=t[p][num];
	}
}
int work(int a)
{
    
    
	int sum=0;
	int p=1;
	for(int k=30;k>=0;k--)
	{
    
    
		num=a>>k&1;
		if(t[p][!num])
		{
    
    
			sum=sum|(1<<k);
			p=t[p][!num];
		}
		else
			p=t[p][num];
	}
	return sum;
}
int main()
{
    
    //freopen("test.in","r",stdin);freopen("test.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
    
    
		scanf("%lld",&x);
		insert(x);
		ans=max(ans,work(x));
	}
	cout<<ans;
	return 0;
}

Then ac happily.
But there is a big guy who wrote

#include<bits/stdc++.h>
using namespace std;
string s;
int t[1000100][30],tot=1;
void add(string str)
{
    
    
	int len=str.size();
	int p=1;
	for(int i=0;i<len;i++)
	{
    
    
		int ch=str[i]-'A';
		if(t[p][ch]==0) t[p][ch]=++tot;
		p=t[p][ch];
	}
}
int main()
{
    
    
	while(getline(cin,s))
	add(s);
	cout<<tot;
	return 0;
}

In this way, basically just add a special judgment to the big data, so the hyp boss and I happily ran 5 sets of data and stuck the man. After all, questions that I haven't done violently can't be done by others.
After the retest, I found that my 80-point code can only get 36 points, but the 60-point code can get 72 points

Severely crack down on other people’s deception, and at the same time increase their deception

Insert picture description here

Guess you like

Origin blog.csdn.net/ydsrwex/article/details/113613276