이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
map<char, int> cmp = {{'A', 0}, {'C', 1}, {'G', 2}, {'U', 3}};
struct T {
array<T*, 4> nxt;
vector<int> idx;
template<class it>
void insert(it st, it en, int i) {
idx.push_back(i);
if (st == en) return;
auto &x = nxt[cmp[*st]];
if (!x) x = new T();
x->insert(next(st), en, i);
}
template<class it>
int query(it st, it en, int l, int r) { // [l, r)
if (st == en)
return lower_bound(all(idx), r) - lower_bound(all(idx), l);
auto &x = nxt[cmp[*st]];
return x ? x->query(next(st), en, l, r) : 0;
}
} t;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);
int n,m;
cin>>n>>m;
vector <string> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(all(a));
for(int i=0;i<m;i++){
string s,q;
cin>>s>>q;
auto l=lower_bound(all(a),s)-a.begin();
s.back()++;
auto r=lower_bound(all(a),s)-a.begin();
r--;
if(l>r){
cout<<0<<"\n";
continue;
}
}
cout<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |