Submission #548608

#TimeUsernameProblemLanguageResultExecution timeMemory
548608colossal_pepeSelling RNA Strands (JOI16_selling_rna)C++17
10 / 100
1586 ms4044 KiB
#include <iostream> #include <vector> using namespace std; int n, m; vector<string> S; int solve(string pref, string suf) { int ans = 0; for (int i = 0; i < n; i++) { string cur = S[i]; if (cur.size() < pref.size() or cur.size() < suf.size()) continue; if (cur.substr(0, pref.size()) == pref and cur.substr(cur.size() - suf.size(), suf.size()) == suf) ans++; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; S.resize(n); for (int i = 0; i < n; i++) { cin >> S[i]; } while (m--) { string pref, suf; cin >> pref >> suf; cout << solve(pref, suf) << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...