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

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:21:19: error: 'b' was not declared in this scope
   21 |   if(p<a[i].no||p>b[i])
      |                   ^
/sandbox/1/a.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
/sandbox/1/a.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld%lld",&a[i].no,&a[i].go);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~