# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894446 | 2023-12-28T09:38:37 Z | tamyte | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1500 ms | 1048576 KB |
#include<bits/stdc++.h> #define int int64_t #define all(x) (x).begin(), (x).end() #define UNIQUE(x) \ sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit() using pii = std::pair<int, int>; using namespace std; void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (name.size()) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } int MOD = 1e9 + 7; int oo = 1e18; void solve() { #define test1 int n, m; cin >> n >> m; map<string, vector<int>> preff; map<pair<string, int>, bool> suff; vector<string> arr(n); for (int i = 0; i < n; ++i) { cin >> arr[i]; string now = ""; for (auto& c : arr[i]) { now += c; preff[now].push_back(i); } reverse(arr[i].begin(), arr[i].end()); now = ""; for (auto& c : arr[i]) { now += c; suff[{now, i}] = true; } } for (int i = 0; i < m; ++i) { string p, q; cin >> p >> q; reverse(q.begin(), q.end()); if (preff.find(p) == preff.end()) { cout << "0\n"; continue; } int cnt = 0; for (auto& u : preff[p]) { if (suff.find({q, u}) != suff.end()) { cnt++; } } cout << cnt << "\n"; } } int32_t main () { setIO(""); int t = 1; #ifdef test cin >> t; #endif while (t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1279 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1544 ms | 12220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Runtime error | 1279 ms | 1048576 KB | Execution killed with signal 9 |
9 | Halted | 0 ms | 0 KB | - |