编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80252 | #1021. jwp的区间游戏 | Compile Error | 0 | 0 ms | 0 K | C++ 17 / 744 B | BenChak | 2022-07-16 18:23:23 |
#include <stdio.h>
#include <algorithm>
using namespace std;
struct map {
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) {
if (s[j] == 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:24:13: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
24 | scanf("%lld%lld",&a[i].no,&a[i].go);
| ~~~^ ~~~~~~~~
| | |
| | int*
| long long int*
| %d
/sandbox/1/a.cpp:24:17: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
24 | scanf("%lld%lld",&a[i].no,&a[i].go);
| ~~~^ ~~~~~~~~
| | |
| | int*
| long long int*
| %d
/sandbox/1/a.cpp:36:10: error: 'j' was not declared in this scope
36 | if(s[j]==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);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~