SRM 546 div2

  早晨7点到实验室一翻邮箱看到tc的邮件。。。srm 546,因为昨晚去复习,没来实验室,所以不知到又比赛。T_T 早晨抽出一小时翻了翻。。。

250pt

水题

550pt

不好想,反正我的思路很复杂,写难产了。然后看到别人的写,无语的是就几行代码搞定。不得不佩服啊

class TwoRectangles {
public:
    string describeIntersection(vector <int> A, vector <int> B) {
        int c[4];
        c[0] = max(A[0], B[0]);
        c[1] = max(A[1], B[1]);
        c[2] = min(A[2], B[2]);
        c[3] = min(A[3], B[3]);
        
        if(c[0] == c[2] && c[1] == c[3])    return "point";
        if(c[0] < c[2] && c[1] < c[3])    return "rectangle";
        if(c[0] > c[2] || c[1] > c[3])    return "none";
        return "segment";
    }
};
posted @ 2012-06-17 15:39  AC_Von  阅读(154)  评论(0编辑  收藏  举报