CF 456A(Laptops-排序)

本文通过编程解决了一个关于笔记本电脑价格与质量是否成正比的问题。通过对输入数据进行排序和对比,判断是否存在价格较低但质量更高的笔记本电脑,以此来验证价格与质量之间的关系。

A. Laptops
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly smaller) than the price of the second laptop but the quality of the first laptop is higher (strictly greater) than the quality of the second laptop.

Please, check the guess of Alex. You are given descriptions of n laptops. Determine whether two described above laptops exist.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of laptops.

Next n lines contain two integers each, ai and bi (1 ≤ ai, bi ≤ n), where ai is the price of the i-th laptop, and bi is the number that represents the quality of the i-th laptop (the larger the number is, the higher is the quality).

All ai are distinct. All bi are distinct.

Output

If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes).

Sample test(s)
input
2
1 2
2 1
output
Happy Alex

先按b排序,再比较a


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (100000+10)
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
struct node
{
	int a,b;
	friend bool operator<(node a,node b){return a.b<b.b;	}
}a[MAXN];
int n;
int main()
{
	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	cin>>n;
	For(i,n) scanf("%d%d",&a[i].a,&a[i].b);
	sort(a+1,a+1+n);
	For(i,n-1) if (a[i].a>a[i+1].a) {cout<<"Happy Alex"<<endl; return 0;	}
	
	
	cout<<"Poor Alex"<<endl;
	return 0;
}




<think>好的,我现在需要帮助用户解决如何将本地分支与远程分支 origin/laptops_onsite/configs 关联的问题。用户提到了使用 git push --set-upstream 命令,我需要结合提供的引用内容来给出正确的步骤。 首先,用户的问题是关于关联本地分支和远程分支的。根据引用[3]中的信息,使用 git push --set-upstream 或 -u 参数可以设置上游分支。例如,git push -u origin 分支名 会将本地分支推送到远程,并建立追踪关系。 接下来,查看用户提供的引用内容。引用[1]提到使用 git branch --set-upstream-to=origin/<branch> 来建立关联。引用[2]中的例子显示,当执行 git pull 时如果出现需要设置追踪的情况,可以使用 git branch --set-upstream-to=origin/master master,但因为本地没有master分支而失败,需要先切换到master。引用[3]详细说明了git push时如何用--set-upstream设置默认主机,并提到版本差异可能导致的问题。 用户的具体远程分支是 origin/laptops_onsite/configs,这里可能需要确认远程分支是否存在。如果不存在,可能需要先推送创建。假设用户已经在本地创建了分支,并希望推送到该远程分支并关联。 步骤可能包括: 1. 确保本地分支存在并切换到该分支。 2. 使用 git push -u origin local_branch:remote_branch 格式推送到指定的远程分支,并建立关联。 3. 或者使用 git branch --set-upstream-to 手动设置关联。 需要注意的是,远程分支名可能包含斜杠,需要正确转义或使用引号。例如,origin/laptops_onsite/configs 是一个合法的远程分支名,但在命令中可能需要使用完整的引用。 另外,引用[4]提到了删除分支的方法,但用户的问题是关于关联,所以这部分可能暂时不需要考虑。 可能的命令是: git checkout -b local_configs # 如果本地分支不存在,先创建并切换 git push --set-upstream origin local_configs:laptops_onsite/configs 或者,如果本地分支名与远程不同部分相同,可以简化为: git push -u origin laptops_onsite/configs 但需要确认本地分支是否存在,或者是否需要先创建。 总结步骤: 1. 创建并切换到本地分支(如果需要)。 2. 执行 git push --set-upstream 将本地分支推送到远程,并指定远程分支名。 3. 验证关联是否成功,使用 git branch -vv 查看跟踪关系。 需要提醒用户注意远程分支名的正确性,以及是否已经有存在的远程分支,避免冲突。同时,如果远程分支不存在,推送时会自动创建。</think>要将本地分支与远程分支 `origin/laptops_onsite/configs` 关联,可以按照以下步骤操作: --- ### **步骤说明** 1. **确保本地分支存在并切换** 如果本地分支尚未创建,需先创建并切换到该分支: ```bash git checkout -b your_local_branch_name ``` 2. **设置关联并推送代码** 使用 `git push --set-upstream`(或简写 `-u`)将本地分支与远程分支关联: ```bash git push --set-upstream origin your_local_branch_name:laptops_onsite/configs ``` 或更简化的形式(若本地分支名与远程分支名相同): ```bash git push -u origin laptops_onsite/configs ``` 3. **验证关联关系** 运行以下命令查看分支追踪状态: ```bash git branch -vv ``` 若成功关联,会显示类似: ``` * your_local_branch_name 123abcd [origin/laptops_onsite/configs] Commit Message ``` --- ### **注意事项** 1. **远程分支名合法性** 分支名含斜杠(如 `laptops_onsite/configs`)是合法的,但需确保远程仓库允许此命名规则。 2. **分支存在性** - 若远程分支 `laptops_onsite/configs` 已存在,需先拉取最新代码避免冲突。 - 若远程分支不存在,上述命令会自动创建它。 3. **关联其他已存在分支** 若本地分支已存在,但未关联远程分支,可直接设置上游: ```bash git branch --set-upstream-to=origin/laptops_onsite/configs your_local_branch_name ``` --- ### **引用说明** - `git push --set-upstream` 用于建立分支追踪关系并推送代码,后续可直接使用 `git push` 简化操作[^3]。 - 关联失败时,需检查 `.git/config` 文件中的分支配置是否缺失或冲突。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值