QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303680#5075. Fenwick TreeerduolongCompile Error//C++20487b2024-01-12 21:07:442024-01-12 21:07:45

Judging History

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

  • [2024-01-12 21:07:45]
  • 评测
  • [2024-01-12 21:07:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 100005
int T,n,c[N],val0[N],val1[N];
char s[N];
inline void solve(){
	cin>>n>>s+1;
	for(int i=1;i<=n;i++) c[i]=s[i]-'0',val0[i]=val1[i]=0;
	for(int i=1;i<=n;i++){
		int f=i+(i&-i);
		if(f>n) continue;
		if(c[i]) val1[f]++;
		else val0[f]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(c[i]) ans+=!val1[i];
		else ans+=val1[i]==1;
	}
	cout<<ans<<endl;
}
int main(){
	cin>>T;
	while(T--) solve();
	return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:7:15: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘char*’)
    7 |         cin>>n>>s+1;
      |         ~~~~~~^~~~~
      |            |     |
      |            |     char*
      |            std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: 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)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:7:18: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
    7 |         cin>>n>>s+1;
      |                 ~^~
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:7:18: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
    7 |         cin>>n>>s+1;
      |                 ~^~
      |                  |
      |                  char*
answer.code:7:18: error: cannot bind rvalue ‘(short int)(((char*)(& s)) + 1)’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: 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)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:7:18: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
    7 |         cin>>n>>s+1;
      |                 ~^~
      |                  |
      |                  char*
answer.code:7:18: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s)) + 1)’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:7:18: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
    7 |         cin>>n>>s+1;
      |                 ~^~
      |                  |
      |                  char*
answer.code:7:18: error: cannot bind rvalue ‘(int)(((char*)(& s)) + 1)’ to ‘int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:182: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>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:182:7: note:   conversion of argument 1 would be ill-formed:
answ...