Submission #365418

# Submission time Handle Problem Language Result Execution time Memory
365418 2021-02-11T15:53:39 Z BartolM Selling RNA Strands (JOI16_selling_rna) C++17
10 / 100
2 ms 1132 KB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
typedef pair <pii, pii> ppp;

const int INF=0x3f3f3f3f;
const int N=105;
const int MAX=2e6+5;

int n, q, len;
char inp[N];
string str;
string s[N];
int cnt[N];

void solve() {
    for (int i=0; i<q; ++i) {
        memset(cnt, 0, sizeof cnt);
        scanf("%s", inp);
        str=inp;
        for (int j=0; j<n; ++j) {
            if (str.size()>s[j].size()) continue;
            if (s[j].substr(0, str.size())==str) ++cnt[j];
        }
        scanf("%s", inp);
        str=inp;
        int res=0;
        for (int j=0; j<n; ++j) {
            if (str.size()>s[j].size()) continue;
            if (s[j].substr((int)s[j].size()-(int)str.size(), str.size())==str) ++cnt[j];
            if (cnt[j]==2) ++res;
        }
        printf("%d\n", res);
    }
}

void load() {
    scanf("%d %d", &n, &q);
    for (int i=0; i<n; ++i) {
        scanf("%s", inp);
        s[i]=inp;
    }
}

int main() {
    load();
    solve();
    return 0;
}

Compilation message

selling_rna.cpp: In function 'void solve()':
selling_rna.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%s", inp);
      |         ~~~~~^~~~~~~~~~~
selling_rna.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |         scanf("%s", inp);
      |         ~~~~~^~~~~~~~~~~
selling_rna.cpp: In function 'void load()':
selling_rna.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
selling_rna.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |         scanf("%s", inp);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Runtime error 2 ms 1132 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -