Submission #876276

# Submission time Handle Problem Language Result Execution time Memory
876276 2023-11-21T13:35:54 Z Nurislam Selling RNA Strands (JOI16_selling_rna) C++14
35 / 100
1500 ms 3520 KB
#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
map<string, int> mp;
void solve(){
	int n, m;
	cin >> n >> m;
	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

selling_rna.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 433 ms 2704 KB Output is correct
2 Execution timed out 1535 ms 3520 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 604 KB Output is correct
2 Correct 1132 ms 528 KB Output is correct
3 Correct 1106 ms 816 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 987 ms 852 KB Output is correct
6 Correct 1041 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 433 ms 2704 KB Output is correct
9 Execution timed out 1535 ms 3520 KB Time limit exceeded
10 Halted 0 ms 0 KB -