QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#237150#6836. A Plus B ProblemAndy#Compile Error//C++202.2kb2023-11-04 13:20:282023-11-04 13:20:28

Judging History

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

  • [2023-11-04 13:20:28]
  • 评测
  • [2023-11-04 13:20:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	char c=getchar();
	int f=1,x=0;
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return f*x;
}
const int N=1e6+5;
char s[N];
int n,q;
int num[4][N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>q;
	cin>>s+1;
	for(int i=1;i<=n;i++)
		num[1][i]=s[i]-'0';
	cin>>s+1;
	for(int i=1;i<=n;i++)
		num[2][i]=s[i]-'0';
	int res=0;
	set<int> v;
	for(int i=n;i>=1;i--)
	{
		if(num[2][i]+num[1][i]!=9)
			v.insert(i);
		if(num[1][i]+num[2][i]+res>=10)
		{
			num[3][i]=(num[1][i]+num[2][i]+res)%10;
			res=1;
		}
		else
		{
			num[3][i]=num[1][i]+num[2][i]+res;
			res=0;
		}
		//cout<<num[3][i]<<' ';
	}
    v.insert(0);
	int r,c,d;
	int ans=0;
	while(q--)
	{
		cin>>r>>c>>d;
	    auto u=v.upper_bound(c);
		int flag=0;
		if(u==v.end());
		else
		{
			if(num[1][*u]+num[2][*u]>9)flag=1;
		}
		if(num[r][c]==d)
		{
			cout<<(num[1][c]+num[2][c]+flag)%10<<" 0\n";
		}
		if(num[1][c]+num[2][c]+flag<=9)
		{
			if(num[3-r][c]+d+flag<=9)
			{
				num[3][c]=num[3-r][c]+d+flag;
				num[r][c]=d;
				cout<<num[3][c]<<" 2\n";
				if(num[1][c]+num[2][c]==9)v.erase(c);
				else v.insert(c);
				continue;
			}
			else
			{
				ans=2;
				//cout<<num[3-r][c]<<' '<<d<<endl;
				num[3][c]=(num[3-r][c]+d+flag)%10;
				num[r][c]=d;
				if(num[1][c]+num[2][c]==9)v.erase(c);
				else v.insert(c);
				auto bef=v.lower_bound(c);
				bef--;
				if(*bef)
					ans+=c-*bef;
				else ans+=c-*bef-1;
				cout<<num[3][c]<<' '<<ans<<'\n';
				continue;
			}
		}
		else
		{
			if(num[3-r][c]+d+flag<=9)
			{
				ans=2;
				num[3][c]=num[3-r][c]+d+flag;
				num[r][c]=d;
				if(num[1][c]+num[2][c]==9)
					v.erase(c);
				else v.insert(c);
				auto bef=v.lower_bound(c);
				bef--;
				if(*bef)
					ans+=c-*bef;
				else ans+=c-*bef-1;
				cout<<num[3][c]<<' '<<ans<<'\n';
				continue;
			}
			else
			{
				ans=2;
				num[3][c]=(num[3-r][c]+d+flag)%10;
				num[r][c]=d;
				if(num[1][c]+num[2][c]==9)v.erase(c);
				else v.insert(c);
				cout<<num[3][c]<<' '<<ans<<'\n';
			}
		}
	}
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:19:12: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   19 |         cin>>s+1;
      |         ~~~^~~~~
      |         |     |
      |         |     char*
      |         std::istream {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:19:15: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   19 |         cin>>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:19:15: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   19 |         cin>>s+1;
      |              ~^~
      |               |
      |               char*
answer.code:19:15: 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:19:15: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   19 |         cin>>s+1;
      |              ~^~
      |               |
      |               char*
answer.code:19:15: 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:19:15: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   19 |         cin>>s+1;
      |              ~^~
      |               |
      |               char*
answer.code:19:15: 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:
answer.code:19:15: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   19 |         cin>...