求助,本地没问题评测编译没过
查看原帖
求助,本地没问题评测编译没过
548792
zhyx楼主2021/10/21 22:27

求助

这里是代码

#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll n,s=0,price,time,front=0,back=0;
bool isbus;
struct ticket{
	ll price,time;
	bool check(ll p,ll t){
		return p<=price && (t-time)<=45;
	}
}a[100001];

int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>isbus>>price>>time;
		if(isbus){
			bool isfound = false;
			for(int j=back;j<front;++j){
				if( a[j].check(price,time) ){
					back++;
					isfound = true;
					break;
				}
			}
			if(!isfound){
				s+=price;
			}
		}else{//subway
			s+=price;
			a[front].price = price;
			a[front].time = time;
			front++;
		}
	}
	cout<<s;
    return 0;
}

这里是报错信息

/tmp/compiler_9xk8txbt/src:5:22: 错误:‘long long int time’被重新声明为不同意义的符号
 ll n,s=0,isbus,price,time,front=0,back=0;
                      ^~~~
In file included from /usr/include/pthread.h:24,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/gthr.h:148,
                 from /usr/include/c++/8/ext/atomicity.h:35,
                 from /usr/include/c++/8/bits/ios_base.h:39,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/time.h:75:15: 附注:previous declaration ‘time_t time(time_t*)’
 extern time_t time (time_t *__timer) __THROW;
               ^~~~
/tmp/compiler_9xk8txbt/src: 在函数‘int main()’中:
/tmp/compiler_9xk8txbt/src:16:20: 错误:no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘time_t(time_t*) throw ()’ {aka ‘long int(long int*)’})
   cin>>isbus>>price>>time;
   ~~~~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:120:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(__istream_type& (*__pf)(__istream_type&))
       ^~~~~~~~
/usr/include/c++/8/istream:120:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)’ {aka ‘std::basic_istream<char>& (*)(std::basic_istream<char>&)’} [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:124:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’ <near match>
       operator>>(__ios_type& (*__pf)(__ios_type&))
       ^~~~~~~~
/usr/include/c++/8/istream:124:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:131:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(ios_base& (*__pf)(ios_base&))
       ^~~~~~~~
/usr/include/c++/8/istream:131:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘std::ios_base& (*)(std::ios_base&)’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:168:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(bool& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:168:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 警告:‘time_t time(time_t*)’的地址永远不会为 NULL [-Waddress]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:cannot bind non-const lvalue reference of type ‘bool&’ to an rvalue of type ‘bool’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:172:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ <near match>
       operator>>(short& __n);
       ^~~~~~~~
/usr/include/c++/8/istream:172:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘short int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(short int)time’绑定到‘short int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:175:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(unsigned short& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:175:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘short unsigned int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(short unsigned int)time’绑定到‘short unsigned int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:179:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ <near match>
       operator>>(int& __n);
       ^~~~~~~~
/usr/include/c++/8/istream:179:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(int)time’绑定到‘int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:182:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(unsigned int& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:182:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘unsigned int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(unsigned int)time’绑定到‘unsigned int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:186:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(long& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:186:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘long int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(long int)time’绑定到‘long int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:190:7: 附注: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>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(unsigned long& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:190:7: 附注:  conversion of argument 1 would be ill-formed:
/tmp/compiler_9xk8txbt/src:16:22: 错误:invalid conversion from ‘time_t (*)(time_t*) throw ()’ {aka ‘long int (*)(long int*)’} to ‘long unsigned int’ [-fpermissive]
   cin>>isbus>>price>>time;
                      ^~~~
/tmp/compiler_9xk8txbt/src:16:22: 错误:无法将右值‘(long unsigned int)time’绑定到‘long unsigned int&’
In file included from /usr/include/c++/8/iostream:40,
                 from /tmp/compiler_9xk8txbt/src:1:
/usr/include/c++/8/istream:195:7: 附注: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>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ <near match>
       operator>>(long long& __n)
       ^~~~~~~~
/usr/include/c++/8/istream:195
2021/10/21 22:27
加载中...