QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#801085#9810. Obliviate, Then ReincarnateWilliamHuCompile Error//C++201.6kb2024-12-06 18:19:232024-12-06 18:19:23

Judging History

This is the latest submission verdict.

  • [2024-12-06 18:19:23]
  • Judged
  • [2024-12-06 18:19:23]
  • Submitted

answer


#include<bits/stdc++.h>
#pragma optimize(2)
#define int long long
using namespace std;
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int n, m, k;
char s[1000010], p[1000010];
int mod = 1e9+7;
int M[4] = {0, 1, 3, 2};
int c[1000010], a[1000010], b[1000010];
int pows[1000010];
signed main()
{
	pows[0] = 1;
	for(int i = 1;i <= 1e6;i ++)pows[i] = pows[i - 1] * 4 % mod;
	for(int i = 1;i <= 1e6;i ++)pows[i] = (pows[i] + pows[i - 1]) % mod;
	int T = read();
	while(T --)
	{
		
		cin>>s+1;
		cin>>p+1;
		
		k = read();
		n = strlen(s + 1);
		m = strlen(p + 1);
		int len = max(n, m) + (max(n, m) & 1ll), maxn = 0;
		for(int i = 1;i <= len;i ++)
		{
			if(i <= n)a[i] = s[n - i + 1] - '0';
			else a[i] = 0;
			if(i <= m)b[i] = p[m - i + 1] - '0';
			else b[i] = 0;
		}
		len /= 2;
		for(int i = 1;i <= len;i ++)
		{
			int fi = a[(i<<1) - 1] ^ b[(i<<1) - 1];
			int se = a[(i<<1)] ^ b[(i<<1)];
			int x = fi + se * 2;
			//cout<<i<<' '<<x<<endl;
			if(x != 0)maxn = i;
			c[i] = M[x];
		}
		if(! maxn)
		{
			cout<<(pows[k - 1] - 1 + mod) % mod<<'\n';
		}
		else if(k > maxn)
		{
			cout<<-1<<'\n';
		}
		else
		{
			c[k - 1] = 4;
			int ans = 0;
			for(int i = 1;i <= len;i ++)
			{
				//cout<<c[i]<<' '<<pows[i]<<endl;
				ans = (ans + c[i] * pows[i - 1] % mod) % mod;
			}
			cout<<ans<<'\n';
		}
		for(int i = 1;i <= len;i ++)a[i] = b[i] = '0';
	}
	return 0;
}


Details

answer.code: In function ‘int main()’:
answer.code:37:20: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   37 |                 cin>>s+1;
      |                 ~~~^~~~~
      |                 |     |
      |                 |     char*
      |                 std::istream {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:2:
/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:37:23: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   37 |                 cin>>s+1;
      |                      ~^~
/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:37:23: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   37 |                 cin>>s+1;
      |                      ~^~
      |                       |
      |                       char*
answer.code:37:23: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s)) + 1)’ 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:37:23: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   37 |                 cin>>s+1;
      |                      ~^~
      |                       |
      |                       char*
answer.code:37:23: error: cannot bind rvalue ‘(long long int)(((char*)(& s)) + 1)’ 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:37:23: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   37 |                 cin>>s+1;
      |                      ~^~
      |                       |
      |                       char*
answer.code:37:23: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s)) + 1)’ 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:37:23: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   37 |                 cin>>s+1;
      |                      ~^~
      |                       |
      |                       char*
answer.code:37:23: error: cannot bind rvalue ‘(long int)(((char*)(& s)) + 1)’ 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:37:23: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   37 |                 cin>>s+1;
      |                      ~^~
      |                       |
      |             ...