编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#23910 #1004. D. 成立西安“全天候”量化科技有限公司 Compile Error 0 0 ms 0 K C++ / 925 B 电类935-郑新宇 2020-02-24 21:40:07
显示原始代码
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <cstring>
#define ll long long
using namespace std;
struct star {
    ll x, y, z;
} kk[300010];
int t, n, cnt;
multiset<int> m;
bool cmp(star a, star b) {
    if (a.x == b.x) {
        if (a.y == b.y)
            return a.z < b.z;
        else
            return a.y < b.y;
    }
    return a.x < b.x;
}
ll read() {
    ll xx = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') ch = getchar();
    while (ch >= '0' && ch <= '9') {
        xx = xx * 10 + ch - '0';
        ch = getchar();
    }
    return xx;
}
int main() {
    //	freopen("in.txt","r",stdin);
    cin >> t;
    while (t--) {
        cnt = 0;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            kk[i].x = read();
            kk[i].y = read();
            kk[i].z = read();
        }
        sort(kk + 1, kk + n + 1, cmp);
        for (int i = 1; i <= n; i++) {
            if (kk[i].z == 1) {
                auto tt = m.lower_bound(kk[i].y);
                if (tt != m.begin()) {
                    cnt++;
                    m.erase(prev(tt));
                }
            } else
                m.insert(kk[i].y);
        }
        cout << cnt << endl;
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:38:10: error: 'tt' does not name a type; did you mean 't'?
     auto tt = m.lower_bound(kk[i].y);
          ^~
          t
/sandbox/1/a.cpp:39:9: error: 'tt' was not declared in this scope
     if( tt!= m.begin()){
         ^~
/sandbox/1/a.cpp:39:9: note: suggested alternative: 't'
     if( tt!= m.begin()){
         ^~
         t
/sandbox/1/a.cpp:41:14: error: 'prev' was not declared in this scope
      m.erase(prev(tt));
              ^~~~
/sandbox/1/a.cpp:41:14: note: 'std::prev' is only available from C++11 onwards