Codeforces_733_D

Posted 冷暖知不知

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces_733_D相关的知识,希望对你有一定的参考价值。

http://codeforces.com/problemset/problem/733/D

 

先给边排序,然后按3条边排序,只要判断相邻是否能组成长方体。

 

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

struct xxx
{
    int a,b,c,p;
}xx[100005];
int n,x[3];

bool cmp(xxx X,xxx Y)
{
    if(X.a == Y.a && X.b == Y.b)    return X.c > Y.c;
    if(X.a == Y.a)  return X.b > Y.b;
    return X.a > Y.a;
}
int main()
{
    scanf("%d",&n);
    int maxx = 0,ans = 1,ans1,ans2;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d%d%d",&x[0],&x[1],&x[2]);
        sort(x,x+3);
        xx[i].a = x[2];
        xx[i].b = x[1];
        xx[i].c = x[0];
        xx[i].p = i;
        if(xx[i].c > maxx)
        {
            maxx = xx[i].c;
            ans1 = i;
        }
    }
    sort(xx+1,xx+n+1,cmp);
    for(int i = 1;i < n;i++)
    {
        if(xx[i].a == xx[i+1].a && xx[i].b == xx[i+1].b)
        {
            x[0] = xx[i].a;
            x[1] = xx[i].b;
            x[2] = xx[i].c+xx[i+1].c;
            sort(x,x+3);
            if(x[0] > maxx)
            {
                ans = 2;
                maxx = x[0];
                ans1 = xx[i].p;
                ans2 = xx[i+1].p;
            }
        }
    }
    if(ans == 1)    printf("1\n%d\n",ans1);
    else    printf("2\n%d %d\n",ans1,ans2);
    return 0;
}

 

以上是关于Codeforces_733_D的主要内容,如果未能解决你的问题,请参考以下文章

codeforces733D. Kostya the Sculptor 偏序cmp排序,数据结构hash,代码简化

codeforces 733E

Codeforces Round #733 (Div. 1 + Div. 2) D. Secret Santa

Codeforces Round #733 (Div. 1 + Div. 2) D. Secret Santa

Educational Codeforces Round 109 (Rated for Div. 2)- D.Armchairs -01背包泛化物品

Codeforces_723_D