CF733DのKostya彫刻家のアイデア?

タイトル

CF733D

質問の意味を簡素化:

所与\(N- \)直方体、最大内接球の半径を求めて、二つの石は石または上に一緒に、正確に2つの面を一致させることができ、最大内接球の出力は、それを切断しました\(1 \)または\(2 \)石ものです。

分析

真実を話す、この質問は何を言うために教師得ることです\(STLの\)が書かれたが、結果は今、別のスペルを打ち出しています。

明白な結論、内接球の最終半径\(\ DisplayStyle \ FRAC {\分(A、B、C)}、{2} \)ので、目標は、最大最小エッジを作ることを試みることです。

次に、2つのステップ:

  1. 仮定は、それが最短エッジに直方体のこれら三つの側面を見つけることで、接合することができません。次いで、直方体に応じて三方\(X \)最長辺、\(Y \)倍の長辺、\(Z \)最短側部の、およびに従い(X、Y、Zの\) \ 優先順位、ことを見出しました場合答え、レコードレーベル。
  2. ステッチとステッチが、この場合、その後の回答、レコードレーベル、そうでない場合、彼らは答えに寄与しない、それは長辺として最長辺と二つの長方形倍で、一緒に戦うために最短の辺でなければなら試してみてください。
  3. その後、その大きな出力をうまく比較します。
  4. 要約すると、これは知的な質問ダウンの道です。

コード

#include<bits/stdc++.h>

#define file(s) freopen(s".in","r",stdin), freopen(s".out","w",stdout)

#define G ch=getchar()
#define DeBug(x) std::cout<<#x<<':'<<x<<std::endl

const int MaxN=1e5+10;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, G;
        while (!isdigit(ch) && ch^'-') G;
        if (ch=='-') f=-1, G;
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), G;
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

template<typename T>inline bool chkMin(T &a,const T &b) { return a>b ? (a=b, true) : false; }
template<typename T>inline bool chkMax(T &a,const T &b) { return a<b ? (a=b, true) : false; }
template<typename T>inline T min(T a,T b) { return a<b ? a : b; }
template<typename T>inline T max(T a,T b) { return a>b ? a : b; }

struct Orz{int x, y, z, id;} o[MaxN];
inline bool cmp(const Orz a, const Orz b)
{
    if (a.x==b.x)
    {
        if (a.y==b.y) return a.z>b.z;
        else return a.y>b.y;
    }
    else return a.x>b.x;
}

int main()
{
    int n, t[4], ans1=0, ans2=0, pos1=0, pos2=0;
    read(n);
    for (int i=1; i<=n; ++i)
    {
        read(t[1]), read(t[2]), read(t[3]);
        std::sort(t+1, t+4);
        o[i].x=t[3], o[i].y=t[2], o[i].z=t[1], o[i].id=i;
        if (chkMax(ans1, o[i].z)) pos1=i;
    }
    std::sort(o+1, o+n+1, cmp);
    for (int i=1; i<=n; ++i)
        if (o[i].x==o[i+1].x && o[i].y==o[i+1].y)
        {
            int t=min(o[i].y, o[i].z+o[i+1].z);
            if (chkMax(ans2, t)) pos2=i;
        }
    if (ans1>ans2) write(1, '\n'), write(pos1, '\n');
    else write(2, '\n'), write(o[pos2].id, ' '), write(o[pos2+1].id, '\n');
    IO::flush();
    return 0;
}

おすすめ

転載: www.cnblogs.com/G-hsm/p/CF733D.html