結果

問題 No.759 悪くない忘年会にしような!
ユーザー Pachicobue
提出日時 2018-12-07 01:33:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 2,863 ms
コンパイル使用メモリ 223,756 KB
最終ジャッジ日時 2025-01-06 18:34:06
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
struct P
{
    int x, y, z;
    bool operator<(const P& p) const { return x != p.x ? x < p.x : y != p.y ? y < p.y : z < p.z; }
};
struct P2
{
    int y, z;
    bool operator<(const P2& p) const { return y != p.y ? y < p.y : z < p.z; }
};
int main()
{
    int N;
    std::cin >> N;
    std::vector<P> s;
    std::map<P, int> mp;
    for (int i = 0, x, y, z; i < N; i++) { std::cin >> x >> y >> z, s.push_back({x, y, z}), mp[s.back()] = i + 1; }
    std::sort(s.begin(), s.end());
    std::map<P2, int> mp2;
    for (int i = N - 1; i >= 0; i--) {
        const P2 p = {s[i].y, s[i].z};
        if (mp2.find(p) == mp2.end()) { mp2[p] = mp[s[i]]; }
    }
    std::set<P2> ps;
    for (const auto& q : s) {
        const P2 p = {q.y, q.z};
        std::vector<P2> er;
        auto it = ps.upper_bound(p);
        if (it != ps.begin()) {
            it--;
            for (; it->z <= q.z; it--) {
                er.push_back(*it);
                if (it == ps.begin()) { break; }
            }
            for (const auto& e : er) { ps.erase(e); }
        }
        ps.insert(p);
    }
    std::set<int> ans;
    for (const auto& p : ps) { ans.insert(mp2[p]); }
    for (const int i : ans) { std::cout << i << std::endl; }
    return 0;
}
0