Submission #875785

#TimeUsernameProblemLanguageResultExecution timeMemory
875785NurislamSelling RNA Strands (JOI16_selling_rna)C++14
35 / 100
1492 ms1048576 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 pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//~ #define int long long
map<pair<string, string> , int> mp;
void solve(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		for(int k = 0; k < (int)s.size(); k++){
			for(int j = 0; j < (int)s.size(); j++){
				string s1 = s.substr(0, k+1), s2 = s.substr(j);
				mp[{s1, s2}]++;
			}
		}
	}
	for(int i = 0; i < m; i++){
		string a, b;
		cin >> a >> b;
		cout << mp[{a,b}] << '\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:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | 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...