답안 #541312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541312 2022-03-23T02:41:06 Z LittleOrange Selling RNA Strands (JOI16_selling_rna) C++17
0 / 100
1500 ms 8536 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<pair<string,int>> source(n);
    vector<pair<string,int>> rsource(n);
    for (int i = 0;i<n;i++){
        cin >> source[i].first;
        source[i].second = i;
        rsource[i] = source[i];
        reverse(rsource[i].first.begin(),rsource[i].first.end());
    }
    sort(source.begin(),source.end());
    sort(rsource.begin(),rsource.end());
    vector<int> t(n,-1);
    int cur = 1;
    while (m--){
        string p,q;
        cin >> p >> q;
        int ans = 0;
        reverse(q.begin(),q.end());
        auto a = lower_bound(source.begin(),source.end(),make_pair(p,0));
        p[p.size()-1]++;
        auto b = lower_bound(source.begin(),source.end(),make_pair(p,0));
        for (;a!=b;a++){
            t[(*a).second] = cur;
        }
        a = lower_bound(rsource.begin(),rsource.end(),make_pair(q,0));
        q[q.size()-1]++;
        b = lower_bound(rsource.begin(),rsource.end(),make_pair(q,0));
        for (;a!=b;a++){
            if (t[(*a).second] == cur){
                ans++;
            }
        }
        cout << ans << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1572 ms 5052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -