답안 #914281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914281 2024-01-21T14:01:47 Z OAleksa Selling RNA Strands (JOI16_selling_rna) C++14
10 / 100
1500 ms 10712 KB
#include <bits/stdc++.h>
//ako ovaj vaso daso misli da me pobedjuje.....
using namespace std;
#define int long long
#define f first
#define s second
const int N = 1e5 + 69;
const int p = 31;
const int mod = 1e9 + 7;
const int B = 750;
int trie[N][26], node, n, q;
string s[N];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> q;
  	for (int i = 1;i <= n;i++)
  		cin >> s[i];
  	while (q--) {
  		string p, q;
  		cin >> p >> q;
  		int sz1 = p.size();
  		int sz2 = q.size();
  		int ans = 0;
  		for (int i = 1;i <= n;i++) {
  			int ptr1 = 0, ptr2 = q.size() - 1;
  			for (int j = 0;j < s[i].size();j++) {
  				if (ptr1 < sz1 && s[i][j] == p[ptr1]) 
  					ptr1++;
  				else
  					break;
  			}
  			if (ptr1 == sz1) {
  				for (int j = s[i].size() - 1;j >= 0;j--) {
  					if (ptr2 >= 0 && s[i][j] == q[ptr2])
  						ptr2--;
  					else
  						break;
  				}
  				if (ptr2 == -1)
  					++ans;
  			}
  		}
  		cout << ans << '\n';
  	}
	}
  return 0;
}

Compilation message

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |      for (int j = 0;j < s[i].size();j++) {
      |                     ~~^~~~~~~~~~~~~
selling_rna.cpp:28:9: warning: unused variable 'sz2' [-Wunused-variable]
   28 |     int sz2 = q.size();
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4712 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 2 ms 4700 KB Output is correct
7 Correct 2 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1385 ms 10712 KB Output is correct
2 Execution timed out 1528 ms 9904 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1552 ms 4956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4712 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 2 ms 4700 KB Output is correct
7 Correct 2 ms 4696 KB Output is correct
8 Correct 1385 ms 10712 KB Output is correct
9 Execution timed out 1528 ms 9904 KB Time limit exceeded
10 Halted 0 ms 0 KB -