# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332608 | 2020-12-03T01:23:41 Z | casperwang | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1500 ms | 6088 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; const int BLOCK = 1000; int n, m; string s[MAXN]; string p, q; int now, ans; bool pre(string a, string b) { if (a.size() < b.size()) return 0; for (int i = 0; i < b.size(); i++) if (a[i] != b[i]) return 0; return 1; } bool suf(string a, string b) { if (a.size() < b.size()) return 0; for (int i = 0; i < b.size(); i++) if (a[a.size()-1-i] != b[b.size()-1-i]) return 0; return 1; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> s[i]; } sort(s, s+n); for (int i = 0; i < m; i++) { cin >> p >> q; now = lower_bound(s, s+n, p) - s; ans = 0; while (now < n && pre(s[now], p)) { if (suf(s[now], q)) ans++; now++; } cout << ans << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3436 KB | Output is correct |
2 | Correct | 3 ms | 3456 KB | Output is correct |
3 | Correct | 2 ms | 3436 KB | Output is correct |
4 | Correct | 3 ms | 3436 KB | Output is correct |
5 | Correct | 2 ms | 3436 KB | Output is correct |
6 | Correct | 3 ms | 3436 KB | Output is correct |
7 | Correct | 3 ms | 3436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1245 ms | 6088 KB | Output is correct |
2 | Execution timed out | 1586 ms | 5612 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1589 ms | 3436 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3436 KB | Output is correct |
2 | Correct | 3 ms | 3456 KB | Output is correct |
3 | Correct | 2 ms | 3436 KB | Output is correct |
4 | Correct | 3 ms | 3436 KB | Output is correct |
5 | Correct | 2 ms | 3436 KB | Output is correct |
6 | Correct | 3 ms | 3436 KB | Output is correct |
7 | Correct | 3 ms | 3436 KB | Output is correct |
8 | Correct | 1245 ms | 6088 KB | Output is correct |
9 | Execution timed out | 1586 ms | 5612 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |