Submission #876262

#TimeUsernameProblemLanguageResultExecution timeMemory
876262NurislamSelling RNA Strands (JOI16_selling_rna)C++14
60 / 100
1554 ms8148 KiB
#include <bits/stdc++.h> using namespace std; /* <<<<It's never too late for a new beginning in your life>>>> Today is hard tomorrow will worse but the day after tomorrow will be the sunshine.. HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............ Never give up */ //The most CHALISHKANCHIK #define int long long int unordered_map<string, int> mp; void solve(){ int n, m; cin >> n >> m; if(n*m <= 1e8+5e7){ vector<string> v; for(int i = 0; i < n; i++){ string s; cin >> s; v.push_back(s); } for(int i = 0; i < m; i++){ string a, b; cin >> a >> b; int ans = 0; for(int j = 0; j < n; j++){ if(v[j].size() < a.size() || v[j].size() < b.size())continue; if(v[j].substr(0, a.size()) == a && v[j].substr(v[j].size()-b.size()) == b)ans++; } cout << ans << '\n'; } } else { for(int i = 0; i < n; i++){ string s; cin >> s; mp[s]++; } for(int i = 0; i < m; i++){ string a, b; cin >> a >> b; int ans = 0; for(auto k:mp){ if(k.first.size() < max(a.size(), b.size()))continue; string res = k.first; if(res.substr(0, a.size()) == a && res.substr(res.size() - b.size()) == b)ans+=k.second; } cout << ans << '\n'; } } } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int t = 1; //~ cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

selling_rna.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...