Submission #1042233

# Submission time Handle Problem Language Result Execution time Memory
1042233 2024-08-02T17:15:05 Z milo_milkshake Selling RNA Strands (JOI16_selling_rna) C++14
0 / 100
1500 ms 9532 KB
#include <bits/stdc++.h>
using namespace std;
#define uwu "RNA"

typedef long long ll;
#define pb push_back
#define endl '\n'
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
const int N = 1e5 + 3;
const int M = 2e6 + 2;
const int INF = 1e9 + 7;

int n, q;
string s[N];

bool pre(const string& a, const string& b){
    if (a.size() > b.size()) return 0;
    FOR(i, 0, (int) a.size() - 1) if (a[i] != b[i]) return 0;
    return 1;
}
bool suf(const string& a, const string& b){
    int l1 = a.size(), l2 = b.size(); if (l1 > l2) return 0;
    FOR(i, 0, l1 - 1) if (a[i] != b[l2 - i - 1]) return 0;
    return 1;
}
void solve(void){
    while(q--){
        string P, S; cin >> P >> S;
        
        int res = 0;
        FOR(i, 1, n) if (pre(P, s[i]) && suf(S, s[i])) res++;
        cout << res << endl;
    }
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if(fopen(uwu".inp","r")){
        freopen(uwu".inp","r",stdin);
        freopen(uwu".out","w",stdout);
    }

    cin >> n >> q;
    FOR(i, 1, n) cin >> s[i];

    solve();

    cerr << "\nTime used: " << clock() << "ms\n";
    return 0;
}

Compilation message

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen(uwu".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
selling_rna.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(uwu".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 691 ms 9532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1527 ms 3928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3420 KB Output isn't correct
2 Halted 0 ms 0 KB -