Submission #933038

# Submission time Handle Problem Language Result Execution time Memory
933038 2024-02-24T22:47:00 Z vjudge1 Selling RNA Strands (JOI16_selling_rna) C++
10 / 100
1500 ms 5720 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int n, m;
string cad[100000];

bool checa(int pos, string &s1, string &s2){
    if(cad[pos].size()<s1.size() || cad[pos].size()<s2.size())
        return 0;
    int tam=cad[pos].size();
    
    for(int i=0; i<s1.size(); i++){
        if(s1[i]!=cad[pos][i])
            return 0;
    }
    for(int i=s2.size()-1, j=tam-1; i>=0; i--, j--){
        if(s2[i]!=cad[pos][j])
            return 0;
    }
    return 1;
}

void busca(string &s1, string &s2){
    int ans=0;
    for(int i=0; i<n; i++){
        if(checa(i, s1, s2))
            ans++;
    }
    cout<< ans<< "\n";
}

void solve(){
    cin>> n>> m;
    string s1, s2;
    for(int i=0; i<n; i++){
        cin>> cad[i];
    }
    for(int i=0; i<m; i++){
        cin>> s1>> s2;
        busca(s1, s2);
    }
}
 
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int t=1;
    //cin>> t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

selling_rna.cpp: In function 'bool checa(int, std::string&, std::string&)':
selling_rna.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0; i<s1.size(); i++){
      |                  ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 429 ms 5716 KB Output is correct
2 Correct 1193 ms 5656 KB Output is correct
3 Correct 212 ms 5664 KB Output is correct
4 Correct 281 ms 5644 KB Output is correct
5 Correct 202 ms 4700 KB Output is correct
6 Correct 215 ms 4888 KB Output is correct
7 Correct 1239 ms 5404 KB Output is correct
8 Correct 1063 ms 5716 KB Output is correct
9 Correct 1088 ms 5720 KB Output is correct
10 Execution timed out 1567 ms 5644 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1545 ms 3568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 429 ms 5716 KB Output is correct
9 Correct 1193 ms 5656 KB Output is correct
10 Correct 212 ms 5664 KB Output is correct
11 Correct 281 ms 5644 KB Output is correct
12 Correct 202 ms 4700 KB Output is correct
13 Correct 215 ms 4888 KB Output is correct
14 Correct 1239 ms 5404 KB Output is correct
15 Correct 1063 ms 5716 KB Output is correct
16 Correct 1088 ms 5720 KB Output is correct
17 Execution timed out 1567 ms 5644 KB Time limit exceeded
18 Halted 0 ms 0 KB -