Submission #343200

# Submission time Handle Problem Language Result Execution time Memory
343200 2021-01-03T14:09:07 Z Parsa_PG Selling RNA Strands (JOI16_selling_rna) C++14
60 / 100
1500 ms 25324 KB
/* Rastegary Az Shoroe Ye EDAST */
#include <bits/stdc++.h>
     
#define pb push_back
#define endl "\n"
#define ll long long
 
using namespace std;
 
const int maxn = 1e5 + 10 , Maxn = 1e5 + 10, lg = 22; 
const int mod = 22777;
const ll inf = 1e18 + 10;

string s[maxn] , p[maxn] , q[maxn];
 
int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n , m;
	cin >> n >> m;
	for(int i = 0 ; i < n ; i++)
		cin >> s[i];
	for(int i = 0 ; i < m ; i++){
		cin >> p[i] >> q[i];
		reverse(q[i].begin() , q[i].end());
	}
	int l1[maxn] , r1[maxn];
	sort(s , s+n);
	vector<pair<string , int>>v;
	for(int i = 0 ; i < m ; i++){
		l1[i] = lower_bound(s , s + n , p[i]) - s;
		p[i][p[i].size() - 1]++;
		r1[i] = lower_bound(s , s + n , p[i]) - s;
	}
	for(int i = 0 ; i < n ; i++){
		reverse(s[i].begin() , s[i].end());
		v.pb({s[i] , i});
	}
	sort(v.begin() , v.end());
	int in[maxn];
	in[n] = -1;
	for(int i = 0 ; i < n ; i ++)
		s[i] = v[i].first , in[v[i].second] = i;
	int l2[maxn] , r2[maxn];
	for(int i = 0 ; i < m ; i++){
		l2[i] = lower_bound(s , s + n , q[i]) - s;
		q[i][q[i].size() - 1]++;
		r2[i] = lower_bound(s , s + n , q[i]) - s;
	}
	for(int i = 0 ; i < m ; i++){
		int ans = 0;
		for(int j = l1[i] ; j < r1[i] ; j++)
			if(l2[i] <= in[j] && in[j] < r2[i])
				ans++;
		cout << ans << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9708 KB Output is correct
4 Correct 6 ms 9708 KB Output is correct
5 Correct 6 ms 9708 KB Output is correct
6 Correct 6 ms 9708 KB Output is correct
7 Correct 6 ms 9708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 17388 KB Output is correct
2 Correct 64 ms 17748 KB Output is correct
3 Correct 37 ms 17516 KB Output is correct
4 Correct 43 ms 17608 KB Output is correct
5 Correct 29 ms 14792 KB Output is correct
6 Correct 29 ms 14792 KB Output is correct
7 Correct 37 ms 17132 KB Output is correct
8 Correct 40 ms 18248 KB Output is correct
9 Correct 42 ms 19144 KB Output is correct
10 Correct 50 ms 15816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 897 ms 13276 KB Output is correct
2 Correct 373 ms 12044 KB Output is correct
3 Correct 572 ms 12768 KB Output is correct
4 Correct 229 ms 12788 KB Output is correct
5 Correct 134 ms 11744 KB Output is correct
6 Correct 200 ms 12768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9708 KB Output is correct
4 Correct 6 ms 9708 KB Output is correct
5 Correct 6 ms 9708 KB Output is correct
6 Correct 6 ms 9708 KB Output is correct
7 Correct 6 ms 9708 KB Output is correct
8 Correct 29 ms 17388 KB Output is correct
9 Correct 64 ms 17748 KB Output is correct
10 Correct 37 ms 17516 KB Output is correct
11 Correct 43 ms 17608 KB Output is correct
12 Correct 29 ms 14792 KB Output is correct
13 Correct 29 ms 14792 KB Output is correct
14 Correct 37 ms 17132 KB Output is correct
15 Correct 40 ms 18248 KB Output is correct
16 Correct 42 ms 19144 KB Output is correct
17 Correct 50 ms 15816 KB Output is correct
18 Correct 897 ms 13276 KB Output is correct
19 Correct 373 ms 12044 KB Output is correct
20 Correct 572 ms 12768 KB Output is correct
21 Correct 229 ms 12788 KB Output is correct
22 Correct 134 ms 11744 KB Output is correct
23 Correct 200 ms 12768 KB Output is correct
24 Correct 396 ms 18436 KB Output is correct
25 Correct 1160 ms 19384 KB Output is correct
26 Correct 176 ms 18052 KB Output is correct
27 Correct 109 ms 18436 KB Output is correct
28 Execution timed out 1571 ms 25324 KB Time limit exceeded
29 Halted 0 ms 0 KB -