编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#80256 #1021. jwp的区间游戏 Compile Error 0 0 ms 0 K C++ 17 / 724 B BenChak 2022-07-16 18:25:08
显示原始代码
#include <stdio.h>
#include <algorithm>
using namespace std;
struct map {
    long long int no, go, ID;
} a[1000005], b[1000005];
bool s[1000005];
long long int n, ans, p = -1;
bool cmp(map a, map b) { return a.go < b.go; }
bool cmp1(map c, map d) { return c.no < d.no; }
int main() {
    scanf("%lld", &n);
    for (int i = 1; i <= n; ++i) {
        a[i].ID = i;
        b[i].ID = i;
        scanf("%lld%lld", &a[i].no, &a[i].go);
        b[i].no = a[i].no;
        b[i].go = a[i].go;
    }
    sort(a + 1, a + n + 1, cmp);
    sort(b + 1, b + n + 1, cmp1);
    for (int i = 1; i <= n; ++i) {
        if (p <= a[i].no && s[i] == 0) {
            if (s[a[i].ID] == 0 && a[i].go >= a[j].no)
                s[j] = 1;
            //			for(int j=1;j<=n;++j)
            //			{

            //			}
            p = a[i].go;
            ++ans;
        }
    }
    printf("%lld", ans);
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:34:33: error: 'j' was not declared in this scope
   34 |    if(s[a[i].ID]==0&&a[i].go>=a[j].no)
      |                                 ^
/sandbox/1/a.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
/sandbox/1/a.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%lld%lld",&a[i].no,&a[i].go);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~