QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711724#4393. Snatch Grocerieshejinming983282#Compile Error//C++23629b2024-11-05 13:10:312024-11-05 13:10:32

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 13:10:32]
  • 评测
  • [2024-11-05 13:10:31]
  • 提交

answer

#include<iostream>
#include<algorithm>
using namespace std;
struct tie{
	int e;
	int l;
	int qs;
};
bool cmp(tie w,tie s)
{
	if(w.e==s.e)
{ 
       if(w.l==s.l) return w.qs<s.qs;
       else return w.l>s.l;}
       return w.e<s.e;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		tie q[100001];
		for(int i=1;i<=n;i++)
		{
			cin>>q[i].e>>q[i].l;
			q[i].qs=i;
		}
		sort(q,q+n,cmp);
		int sum=0,f=0;
		for(int i=1;i<=n;i++)
		{
				if(q[i+1].e<=q[i].l&&i+1<=n)
				{
					f=1;
					break;
				}
				if(!f) sum=sum+1;
		}
		if(n==1) sum=1;
		cout<<sum<<endl;
	
	}
}

詳細信息

answer.code:9:10: error: reference to ‘tie’ is ambiguous
    9 | bool cmp(tie w,tie s)
      |          ^~~
In file included from /usr/include/c++/13/bits/uses_allocator_args.h:38,
                 from /usr/include/c++/13/bits/memory_resource.h:41,
                 from /usr/include/c++/13/string:58,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/tuple:2155:5: note: candidates are: ‘template<class ... _Elements> constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...)’
 2155 |     tie(_Elements&... __args) noexcept
      |     ^~~
answer.code:4:8: note:                 ‘struct tie’
    4 | struct tie{
      |        ^~~
answer.code:9:16: error: reference to ‘tie’ is ambiguous
    9 | bool cmp(tie w,tie s)
      |                ^~~
/usr/include/c++/13/tuple:2155:5: note: candidates are: ‘template<class ... _Elements> constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...)’
 2155 |     tie(_Elements&... __args) noexcept
      |     ^~~
answer.code:4:8: note:                 ‘struct tie’
    4 | struct tie{
      |        ^~~
answer.code:9:21: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | bool cmp(tie w,tie s)
      |                     ^
answer.code: In function ‘int main()’:
answer.code:25:17: error: reference to ‘tie’ is ambiguous
   25 |                 tie q[100001];
      |                 ^~~
/usr/include/c++/13/tuple:2155:5: note: candidates are: ‘template<class ... _Elements> constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...)’
 2155 |     tie(_Elements&... __args) noexcept
      |     ^~~
answer.code:4:8: note:                 ‘struct tie’
    4 | struct tie{
      |        ^~~
answer.code:28:30: error: ‘q’ was not declared in this scope
   28 |                         cin>>q[i].e>>q[i].l;
      |                              ^
answer.code:31:22: error: ‘q’ was not declared in this scope
   31 |                 sort(q,q+n,cmp);
      |                      ^