Submission #1235538

#TimeUsernameProblemLanguageResultExecution timeMemory
1235538nai0610Selling RNA Strands (JOI16_selling_rna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll int64_t
#define ld long double
using namespace std;
// 
const int maxn =1e5+5;
const int maxm =2e6+5;
const int mod = 1e9+7; // 998244353,1610612741
const ll inf = 1e18;
const ld pi = atan(1.0L)*4;
int n,Q,m[420];
int t[2][maxm][4],it[2],L[maxm],R[maxm];
string a[maxn];
vector<int> pos[maxm];
void add(int id,const string& s,int i,bool rev){
	int u=1;
	for (int j=0;j<s.size();j++) {
		int c=m[(rev?s[s.size()-1-j]:s[j])];
		if (!t[id][u][c]) t[id][u][c]=++it[id];
		u=t[id][u][c];
		if (id==0) {
			if (!L[u]) L[u]=i;
			R[u]=i;
		}
		else pos[u].push_back(i);
	}
}
int get(int id,const string& s,bool rev) {
	int u=1;
	for (int j=0;j<s.size();j++) {
		int c=m[(rev?s[s.size()-1-j]:s[j])];
		u=t[id][u][c];
		if (!u) return 0;
	}
	return u;
}
int main() {
    // freopen("../input.inp","r",stdin);
    // freopen("output.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    clock_t start,end;
	start=clock();
	m['A']=0;
	m['G']=1;
	m['C']=2;
	m['U']=3;
	cin >>n>>Q;
	it[0]=it[1]=1;
	for (int i=1;i<=n;i++) cin >>a[i];
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++) {
		add(0,a[i],i,0);
		add(1,a[i],i,1);
	}
	while (Q--) {
		string p,q;
		cin >>p>>q;
		int u=get(0,p,0),v=get(1,q,1);
		cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
					 lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
	}
	end=clock();
	ld dur=(ld)(end-start)/(ld)(CLOCKS_PER_SEC)*(1000.0L);
	cerr<<dur<<'\n';
    return 0;
}

Compilation message (stderr)

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:60:27: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   60 |                 cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                                          lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from selling_rna.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:60:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   60 |                 cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                                          lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from selling_rna.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:60:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   60 |                 cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                                          lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 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 selling_rna.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:60:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |                 cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                                          lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 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 selling_rna.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:60:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |                 cout <<max(0,upper_bound(pos[v].begin(),pos[v].end(),R[u])-
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                                          lower_bound(pos[v].begin(),pos[v].end(),L[u]))<<'\n';
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~