제출 #788690

#제출 시각아이디문제언어결과실행 시간메모리
788690Dan4LifeSelling RNA Strands (JOI16_selling_rna)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define all(a) begin(a),end(a) const int mxN = (int)1e5+10; const int mxS = (int)2e6+10; int trie[2][4][mxS]; int L[mxS], R[mxS]; int n,m,node=2; string s[mxN]; vector<int> xd[mxS]; void add(string &s, int ind, int t){ int v = 1; for(auto u : s){ int c = (u=='A'?0:u=='C'?1:u=='G'?2:3); if(!trie[t][c][v]) trie[t][c][v]=node++; v = trie[t][c][v]; if(!t){ if(!L[v]) L[v]=ind; R[v]=max(R[v],ind); } else xd[v].pb(ind); } } int get(string &s, int t){ int v = 1; for(auto u : s){ int c = (u=='A'?0:u=='C'?1:u=='G'?2:3); if(!trie[t][c][v]) return 0; v = trie[t][c][v]; } return v; } int32_t main() { cin >> n >> m; for(int i = 0; i < n; i++) cin >> s[i]; sort(s,s+n); for(int i = 0; i < n; i++) add(s[i],i+1,0),reverse(all(s[i])),add(s[i],i+1,1); for(int i = 0; i < m; i++){ string s, t; cin >> s >> t; reverse(all(t)); int ind = get(s,0), ind2=get(t,1); int l = L[ind], r=R[ind]; if(!l or !ind or !ind2) { cout << "0\n"; continue; } int pos1 = lower_bound(all(xd[ind2]),l)-begin(xd[ind2]); int pos2 = upper_bound(all(xd[ind2]),r)-begin(xd[ind2])-1; cout << max(0ll, pos2-pos1+1) << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

selling_rna.cpp: In function 'int32_t main()':
selling_rna.cpp:51:31: error: no matching function for call to 'max(long long int, int)'
   51 |   cout << max(0ll, pos2-pos1+1) << "\n";
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from selling_rna.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:51:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |   cout << max(0ll, pos2-pos1+1) << "\n";
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from selling_rna.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:51:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |   cout << max(0ll, pos2-pos1+1) << "\n";
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from selling_rna.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:51:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |   cout << max(0ll, pos2-pos1+1) << "\n";
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from selling_rna.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
selling_rna.cpp:51:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |   cout << max(0ll, pos2-pos1+1) << "\n";
      |                               ^