Campamento de invierno de Petrozavodsk 2019, informe de resolución de problemas de la Copa Yandex

H


Para la pregunta de check-in, el valor máximo del valor mínimo de cada línea es la respuesta.


#include <bits/stdc++.h>

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

int n;
ll Ans,tmp;

int main(){
	n=input();
	for(int i=1;i<=n;i++){
		tmp=0x3f3f3f3f;
		for(int j=1;j<=n;j++)
			tmp=min(tmp,input());
		Ans=max(tmp,Ans);
	}
	printf("%lld\n",Ans);
}

UN


Codicioso, elija el punto con el incremento más pequeño cada vez.


#include <bits/stdc++.h>

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

#define PII pair<int,int>
#define fr first
#define sc second
#define mp make_pair

const int N=3e5+7;

struct node{
	int x,y;
	int id;
	bool operator <(const node &t)const{
		return x+y>t.x+t.y;
	}
}a[N];

int n;

priority_queue <node> Q;

int main(){
	n=input();
	for(int i=1;i<=n;i++){
		a[i].x=input(),a[i].y=input();
		a[i].id=i;
		Q.push(a[i]);
	}

	int x=1,y=1;

	while(!Q.empty()){
		node t=Q.top();Q.pop();
		if(x>t.x){
			t.x=x;
			Q.push(t);
			continue;
		}
		if(y>t.y){
			t.y=y;
			Q.push(t);
			continue;
		}

		printf("%d%c",t.id,Q.empty()? '\n':' ');
		x=max(x,t.x),y=max(t.y,y);
	}
}

J


Vaya a la izquierda y a la derecha, y duplíquelo cada vez (porque necesita resolver el problema dentro de los 30 m.) Cuando llegue a 1, ejecute + y-respectivamente, puede saber fácilmente cuál es la respuesta.


#include <bits/stdc++.h>

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

int main(){
	char c='+';
	int len=1,check;
	while(1){
		for(int i=1;i<=len;i++){
			cout<<c<<endl;
			cin>>check;
			if(check){
				cout<<'+'<<endl;
				cin>>check;
				cout<<'-'<<endl;
				cin>>check;
				if(check) cout<<"! ugly"<<endl;
				else if(c=='+') cout<<"! bad"<<endl;
				else cout<<"! good"<<endl;
				return 0;
			}
		}
		c='+'+'-'-c;
		len*=4;
	}
}

Supongo que te gusta

Origin www.cnblogs.com/-aether/p/12715693.html
Recomendado
Clasificación