编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#58 #1004. D. 成立西安“全天候”量化科技有限公司 Compile Error 0 0 ms 0 K C++ 11 / 1.3 K YangDavid 2019-06-05 23:29:58
显示原始代码
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1, i##_end_ = (n); i <= i##_end_; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

struct item {
    int x, y, z;
    item(int x, int y, int z) : x(x), y(y), z(z) {}
    bool operator<(const item& it) const {
        if (x != it.x)
            return x < it.x;
        if (z != it.z)
            return z > it.z;
        return y < it.y;
    }
};

int n, xp, yp, zp;
vector<item> a;
multiset<int, greater<int> > st;
void solve() {
    a.clear(), st.clear();
    int ans = 0;
    scanf("%d", &n);
    rep(i, n) {
        scanf("%d%d%d", &xp, &yp, &zp);
        a.emplace_back(xp, yp, zp);
    }
    sort(a.begin(), a.end());

    int curx = -1;
    vector<int> topush;

    for (auto g : a) {
        if (curx != g.x) {
            st.insert(topush.begin(), topush.end());
            topush.clear();
            curx = g.x;
        }
        if (g.z == 1) {
            auto p = st.upper_bound(g.y);
            if (p != st.end()) {
                st.erase(p);
                ans++;
            }
            continue;
        }
        topush.push_back(g.y);
    }
    printf("%d\n", ans);
}

int main() {
    int T;
    scanf("%d", &T) while (T--) solve();

    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:53:27: error: expected ';' before 'while'
     int T; scanf("%d", &T)
                           ^
                           ;
     while(T--) solve();
     ~~~~~                  
/sandbox/1/a.cpp: In function 'void solve()':
/sandbox/1/a.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
/sandbox/1/a.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &xp, &yp, &zp);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:53:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int T; scanf("%d", &T)
            ~~~~~^~~~~~~~~~