Submission #548662

# Submission time Handle Problem Language Result Execution time Memory
548662 2022-04-14T07:47:40 Z SlyGaleeb Selling RNA Strands (JOI16_selling_rna) C++17
10 / 100
1111 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ld long double
#define vf v[i].first
#define vs v[i].second

void print(vector<int> &v) {
	for (auto c:v)
		cout << c << " ";
	cout << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m;
	cin >> n >> m;
	vector<string>a(n);
	vector<pair<string,string>>v;
	set<string>pre[5005],suf[5005];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i) {
		string t1,t2;
		int j = 0,k = a[i].size()-1;
		while (j<a[i].size() && k>=0) {
			t1.push_back(a[i][j]);
			t2.insert(0,1,a[i][k]);
			pre[i].insert(t1);
			suf[i].insert(t2);
			j++,k--;
		}
		t1.clear();
		t2.clear();
	}
	for (int i = 0; i < m; ++i) {
		string p,q;
		cin >> p >> q;
		v.push_back({p,q});
	}
	for (int i = 0; i < m; ++i) {
		int ans = 0;
		for (int j = 0; j < n; ++j) {
			if (pre[j].count(vf) && suf[j].count(vs))
				++ans;
		}
		cout << ans << "\n";
	}
}	

Compilation message

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:29:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   while (j<a[i].size() && k>=0) {
      |          ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1111 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 7764 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Runtime error 1111 ms 1048576 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -