Submission #894446

#TimeUsernameProblemLanguageResultExecution timeMemory
894446tamyteSelling RNA Strands (JOI16_selling_rna)C++14
10 / 100
1544 ms1048576 KiB
#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 (stderr)

selling_rna.cpp: In function 'void setIO(std::string)':
selling_rna.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selling_rna.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...