QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#416046#8672. 排队_LibraCompile Error//C++14997b2024-05-21 15:17:442024-05-21 15:17:44

Judging History

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

  • [2024-05-21 15:17:44]
  • 评测
  • [2024-05-21 15:17:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int maxn=1e6+100;
int n,Q;
int l[maxn],r[maxn];

struct P{
	int id,ans;
	int l,r;
}q[maxn];

void solve_sub1(){
	for(int i=1;i<=Q;i++){ 
		int L=q[i].l,R=q[i].r; 
		int num=0;
		for(int i=L;i<=R;i++){
			if(l[i]<=num&&num<=r[i]) num++;
		}
		cout<<num<<endl;
	}
	
}

inline bool cmp1(P a,P b){return a.r<b.r;}
inline bool cmp2(P a,P b){return a.id<b.id;}

void solve_l1(){
	sort(q+1,q+1+Q,cmp1);
	int now=1,num=0;
	for(int i=1;i<=Q;i++){
		while(now<=q[i].r){
			if(l[now]<=num&&num<=r[now]) num++;
			now++;
		} 
		q[i].ans=num;
	}
	sort(q+1,q+1+Q,cmp2);
	for(int i=1;i<=Q;i++){
		cout<<q[i].ans<<endl;
	}
}


bool L1(){
	for(int i=1;i<=Q;i++) if(q[i].l!=1) return 0;
	return 1;
}

int main(){
	
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>l[i]>>r[i];
	for(int i=1;i<=Q;i++) cin>>q[i].l>>q[i].r,q[i].id=i;
	if(n<=5000) return solve_sub1(),0;
	if(L1()) return solve_l1(),0;
	
	
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:52:15: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘P [1000100]’)
   52 |         cin>>n>>q;
      |         ~~~~~~^~~
      |            |    |
      |            |    P [1000100]
      |            std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   52 |         cin>>n>>q;
      |                 ^
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: invalid conversion from ‘P*’ to ‘long long unsigned int’ [-fpermissive]
   52 |         cin>>n>>q;
      |                 ^
      |                 |
      |                 P*
answer.code:52:17: error: cannot bind rvalue ‘(long long unsigned int)((P*)(& q))’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: invalid conversion from ‘P*’ to ‘long long int’ [-fpermissive]
   52 |         cin>>n>>q;
      |                 ^
      |                 |
      |                 P*
answer.code:52:17: error: cannot bind rvalue ‘(long long int)((P*)(& q))’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: invalid conversion from ‘P*’ to ‘long unsigned int’ [-fpermissive]
   52 |         cin>>n>>q;
      |                 ^
      |                 |
      |                 P*
answer.code:52:17: error: cannot bind rvalue ‘(long unsigned int)((P*)(& q))’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: invalid conversion from ‘P*’ to ‘long int’ [-fpermissive]
   52 |         cin>>n>>q;
      |                 ^
      |                 |
      |                 P*
answer.code:52:17: error: cannot bind rvalue ‘(long int)((P*)(& q))’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:17: error: invalid conversion from ‘P*’ to ‘unsigned int’ [-fpermissive]
   52 |         cin>>n>>q;
      |                 ^
      |                 |
      |                 P*
answer.code:52:17: error: cannot bind rvalue ‘(unsigned int)((P*)(& q))’ to ‘unsigned int&’
/usr/include/c++/13/istream:181:7: note: candidate: ‘std::basic_i...