编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80235 | #1021. jwp的区间游戏 | Compile Error | 0 | 0 ms | 0 K | C++ 17 / 533 B | BenChak | 2022-07-16 17:37:34 |
#include <stdio.h>
#include <algorithm>
using namespace std;
struct map {
int no, go, h;
} a[1000005];
int n, ans, p;
bool end[1000005];
bool cmp(map a, map b) { return a.go < b.go; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &a[i].no, &a[i].go);
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; ++i) {
if (p <= a[i].no && end[i] == 0) {
for (int j = 1; j <= n; ++j) {
if (end[j] == 0 && a[i].go >= a[j].no)
end[j] = 1;
}
p = a[i].go;
++ans;
}
}
printf("%lld", ans);
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:23:18: error: reference to 'end' is ambiguous
23 | if(p<=a[i].no&&end[i]==0)
| ^~~
In file included from /usr/include/c++/10/array:41,
from /usr/include/c++/10/tuple:39,
from /usr/include/c++/10/functional:54,
from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
from /usr/include/c++/10/algorithm:74,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/bits/range_access.h:110:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
110 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:109:31: note: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
109 | template<typename _Tp> _Tp* end(valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: 'template<class _Tp, unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/10/utility:76,
from /usr/include/c++/10/algorithm:60,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/initializer_list:101:5: note: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/sandbox/1/a.cpp:8:6: note: 'bool end [1000005]'
8 | bool end[1000005];
| ^~~
/sandbox/1/a.cpp:27:8: error: reference to 'end' is ambiguous
27 | if(end[j]==0&&a[i].go>=a[j].no)
| ^~~
In file included from /usr/include/c++/10/array:41,
from /usr/include/c++/10/tuple:39,
from /usr/include/c++/10/functional:54,
from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
from /usr/include/c++/10/algorithm:74,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/bits/range_access.h:110:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
110 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:109:31: note: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
109 | template<typename _Tp> _Tp* end(valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: 'template<class _Tp, unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/10/utility:76,
from /usr/include/c++/10/algorithm:60,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/initializer_list:101:5: note: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/sandbox/1/a.cpp:8:6: note: 'bool end [1000005]'
8 | bool end[1000005];
| ^~~
/sandbox/1/a.cpp:28:5: error: reference to 'end' is ambiguous
28 | end[j]=1;
| ^~~
In file included from /usr/include/c++/10/array:41,
from /usr/include/c++/10/tuple:39,
from /usr/include/c++/10/functional:54,
from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
from /usr/include/c++/10/algorithm:74,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/bits/range_access.h:110:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
110 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:109:31: note: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
109 | template<typename _Tp> _Tp* end(valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: 'template<class _Tp, unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/10/utility:76,
from /usr/include/c++/10/algorithm:60,
from /sandbox/1/a.cpp:2:
/usr/include/c++/10/initializer_list:101:5: note: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/sandbox/1/a.cpp:8:6: note: 'bool end [1000005]'
8 | bool end[1000005];
| ^~~
/sandbox/1/a.cpp:34:13: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
34 | printf("%lld",ans);
| ~~~^ ~~~
| | |
| | int
| long long int
| %d
/sandbox/1/a.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
/sandbox/1/a.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d%d",&a[i].no,&a[i].go);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~