QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#730910#5311. Master of BothHobertCompile Error//C++201.3kb2024-11-09 22:21:452024-11-09 22:21:50

Judging History

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

  • [2024-11-09 22:21:50]
  • 评测
  • [2024-11-09 22:21:45]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

const int N=1e6+10;

struct Tree{
	map<int,int>to;
	int cnt[27];
}tr[N];

int idx=1;
//map<pair<char,char>,int>mp;
int tl[27][27];


void build(int u,string s,int i){
	int c=s[i]-'`';
	for(auto [j,t]:tr[u].to){
		if(j!=c&&tr[u].to[j]){
			tl[c][j]+=tr[u].cnt[j];
//			mp[{c+'`',j+'`'}]+=tr[u].cnt[j];
//			if(tr[u].cnt[j]) cout<<(char)(c+'`')<<' '<<(char)(j+'`')<<endl;
		}
	}
	if(!tr[u].to[c]){
		tr[u].to[c]=idx;
		idx++;
	}
	tr[u].cnt[c]++;
	if(i+1<(int)s.size()) build(tr[u].to[c],s,i+1);
}

char v[N];

void solve(){
	int n,q;
	cin>>n>>q;
//	vector<string>v(n);
//	for(auto &x:v) cin>>x;
	for(int j=0;j<27;j++) tr[0].to[j]=tr[0].cnt[j]=0;
	
	for(int i=0;i<n;i++){
		cin>>(v+1);
		v[0]='`';
		build(0,v,0);
//		cout<<v[i]<<endl;
	}
	
//	for(auto [x,y]:mp){
//		auto [a,b]=x;
//		if(y) cout<<a<<b<<' '<<y<<endl;
//	}
	while(q--){
		char s[27];
		cin>>(s+1);
		s[0]='`';
		int res=0;
		for(int i=0;i<27;i++){
			for(int j=0;j<i;j++){
//				if(mp[{s[i],s[j]}]) cout<<s[i]<<' '<<s[j]<<endl;
//				res+=mp[{s[i],s[j]}];
				res+=tl[s[j]-'`'][s[i]-'`'];
			}
		}
		cout<<res<<endl;
	}
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
	while(_--) solve();
	return 0;
}

Details

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