Submission #298592

# Submission time Handle Problem Language Result Execution time Memory
298592 2020-09-13T11:01:04 Z BeanZ Selling RNA Strands (JOI16_selling_rna) C++14
0 / 100
1500 ms 5504 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
string s[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        /*f (fopen("test.inp", "r")){
                freopen("test.inp", "r", stdin);
                freopen("test.ans", "w", stdout);
        }*/
        ll n, m;
        cin >> n >> m;
        for (int i = 1; i <= n; i++){
                cin >> s[i];
        }
        while (m--){
                string t, p;
                cin >> t >> p;
                ll res = 0;
                for (int i = 1; i <= n; i++){
                        if (t.length() > s[i].length() || p.length() > s[i].length()){
                                continue;
                        }
                        bool flag = true;
                        for (int j = 0; j < t.length(); j++){
                                if (t[j] != s[i][j]) flag = false;
                        }
                        reverse(s[i].begin(), s[i].end());
                        reverse(p.begin(), p.end());
                        for (int j = 0; j < p.length(); j++){
                                if (p[j] != s[i][j]) flag = false;
                        }
                        reverse(s[i].begin(), s[i].end());
                        if (flag) res++;
                }
                cout << res << endl;
        }
}
/*
*/

Compilation message

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:30:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                         for (int j = 0; j < t.length(); j++){
      |                                         ~~^~~~~~~~~~~~
selling_rna.cpp:35:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                         for (int j = 0; j < p.length(); j++){
      |                                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1544 ms 5504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1548 ms 3608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -