Submission #1297350

#TimeUsernameProblemLanguageResultExecution timeMemory
1297350kqhuy2009Selling RNA Strands (JOI16_selling_rna)C++20
10 / 100
1586 ms34176 KiB
#include <bits/stdc++.h> #define ll long long #define INF (ll)1e18+1 #define bit(mask, id) ((mask >> id) & 1LL) #define pb push_back #define el '\n' #define ft first #define sc second #define ii pair<ll,ll> #define FOR(i, l, r) for (int i = (l); i <= (r); ++i) #define FORD(i, l, r) for(int i = (l); i >= (r); --i) #define str string #define all(a,i) memset(a,i,sizeof(a)) #define al(a) a.begin(),a.end() ///////////////////////////// const long long oo = 1e18; const int N = 1e6 + 9; using namespace std; bool prefix(str s, str t) { if(t.size()>s.size()) return false; FOR(i,0,t.size()-1) { if(t[i]!=s[i]) return false; } return true; } bool suffix(str s, str t) { reverse(s.begin(),s.end()); reverse(t.begin(),t.end()); return prefix(s,t); } ll n, Q; str a[N]; signed main() { #define TASK "rna" if(fopen(TASK ".inp","r")) { freopen (TASK ".inp","r",stdin); //freopen (TASK ".out","w",stdout); freopen (TASK ".ans","w",stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>Q; FOR(i,1,n) cin>>a[i]; FOR(i,1,Q) { str p,q; cin>>p>>q; ll cnt = 0; FOR(j,1,n) { if(prefix(a[j],p) && suffix(a[j],q)) cnt++; } cout<<cnt<<el; } return 0; }

Compilation message (stderr)

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:43:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen (TASK ".inp","r",stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
selling_rna.cpp:45:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen (TASK ".ans","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...