Submission #876262

# Submission time Handle Problem Language Result Execution time Memory
876262 2023-11-21T13:23:08 Z Nurislam Selling RNA Strands (JOI16_selling_rna) C++14
60 / 100
1500 ms 8148 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
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

selling_rna.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 6400 KB Output is correct
2 Correct 570 ms 6404 KB Output is correct
3 Correct 173 ms 6452 KB Output is correct
4 Correct 232 ms 6540 KB Output is correct
5 Correct 517 ms 4216 KB Output is correct
6 Correct 519 ms 4244 KB Output is correct
7 Correct 428 ms 7556 KB Output is correct
8 Correct 963 ms 7992 KB Output is correct
9 Correct 871 ms 8148 KB Output is correct
10 Correct 1396 ms 6100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1116 KB Output is correct
2 Correct 962 ms 968 KB Output is correct
3 Correct 883 ms 868 KB Output is correct
4 Correct 14 ms 860 KB Output is correct
5 Correct 750 ms 912 KB Output is correct
6 Correct 734 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 130 ms 6400 KB Output is correct
9 Correct 570 ms 6404 KB Output is correct
10 Correct 173 ms 6452 KB Output is correct
11 Correct 232 ms 6540 KB Output is correct
12 Correct 517 ms 4216 KB Output is correct
13 Correct 519 ms 4244 KB Output is correct
14 Correct 428 ms 7556 KB Output is correct
15 Correct 963 ms 7992 KB Output is correct
16 Correct 871 ms 8148 KB Output is correct
17 Correct 1396 ms 6100 KB Output is correct
18 Correct 17 ms 1116 KB Output is correct
19 Correct 962 ms 968 KB Output is correct
20 Correct 883 ms 868 KB Output is correct
21 Correct 14 ms 860 KB Output is correct
22 Correct 750 ms 912 KB Output is correct
23 Correct 734 ms 860 KB Output is correct
24 Execution timed out 1554 ms 5356 KB Time limit exceeded
25 Halted 0 ms 0 KB -