QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758533#5311. Master of BothzaqmjuCompile Error//C++201001b2024-11-17 18:44:022024-11-17 18:44:02

Judging History

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

  • [2024-11-17 18:44:02]
  • 评测
  • [2024-11-17 18:44:02]
  • 提交

answer

#include <bits/stdc++.h>
 
typedef long long ll;
const int N = 2e6 + 5;
const int mod = 1e9 + 7;
int n, m, idx;
int sum[N][30];
int pos[30], mp[N][30];
char s[N];
ll cnt[30][30];
 
void insert() {
	int p = 0;
	for(int i = 0; s[i]; i ++) {
		int u = s[i] - 'a' + 1;
		if(!mp[p][u]) mp[p][u] = ++ idx;
		for(int j = 0; j < 27; j ++) {
			cnt[j + 1][u + 1] += sum[p][j];
		}
		sum[p][u] ++;
		p = mp[p][u];
	}
}
 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	std::cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		std::cin >> s;
		int len = strlen(s);
		s[len] = 'a' - 1;
		s[len + 1] = 0;
		insert();
	}
	while(m --) {
		std::cin >> s + 1;
		s[0] = 'a' - 1;
		for(int i = 0; i < 27; i ++) {
			pos[s[i] - 'a' + 1] = i;
		}
		ll ans = 0;
		for(int i = 0; i < 27; i ++) {
			for(int j = 0; j < 27; j ++) {
				if(pos[i] > pos[j])
					ans += cnt[i + 1][j + 1];
			}
		}
		std::cout << ans << '\n';
	}
	return 0;
}

详细

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