제출 #1267563

#제출 시각아이디문제언어결과실행 시간메모리
1267563quangykqhSelling RNA Strands (JOI16_selling_rna)C++20
0 / 100
176 ms59360 KiB
#include<bits/stdc++.h> using namespace std; const int MN=1e5+1209; long long n,m,k,ans,pos[500],MIN; string skibidi[MN],sex[MN],s[MN]; struct trie { struct Node2 { int cnt; Node2 *child[5][5]; Node2() { cnt=0; for(int i=0;i<5;i++) for(int j=0;j<5;j++) child[i][j]=NULL; } }; Node2 *root=new Node2; Node2 *cur=root; void addstring(string &p,string &q) { cur=root; for(int i=0;i<p.length();i++) { if(!cur->child[pos[p[i]]][pos[q[i]]]) cur->child[pos[p[i]]][pos[q[i]]]=new Node2; cur=cur->child[pos[p[i]]][pos[q[i]]]; } } void addstring2(string& s) { root->cnt++; cur=root; for(int i=0;i<s.length();i++) { Node2 *cb=cur; for(int j=i;j<s.length();j++) { if(!cur->child[pos[s[i]]][0])break; cur=cur->child[pos[s[i]]][0]; cur->cnt++; } cur=cb; for(int j=i;j<s.length();j++) { if(!cur->child[0][pos[s[s.length()-i-1]]])break; cur=cur->child[0][pos[s[s.length()-i-1]]]; cur->cnt++; } cur=cb; if(!cur->child[pos[s[i]]][pos[s[s.length()-i-1]]])break; cur=cur->child[pos[s[i]]][pos[s[s.length()-i-1]]]; cur->cnt++; } } int takeans(string &p,string &q) { cur=root; for(int i=0;i<p.length();i++) { cur=cur->child[pos[p[i]]][pos[q[i]]]; } return cur->cnt; } }; trie TRIE; int main() { if(fopen("GAME.INP","r")) { freopen("GAME.INP","r",stdin); freopen("GAME.OUT","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; pos['A']=1; pos['C']=2; pos['U']=3; pos['G']=4; pos['#']=0; for(int i=1;i<=n;i++) { cin>>s[i]; } for(int i=1;i<=m;i++) { cin>>skibidi[i]>>sex[i]; reverse(sex[i].begin(),sex[i].end()); while(sex[i].length()<skibidi[i].length()) sex[i].push_back('#'); while(skibidi[i].length()<sex[i].length()) skibidi[i].push_back('#'); TRIE.addstring(skibidi[i],sex[i]); } for(int i=1;i<=n;i++) { TRIE.addstring2(s[i]); } for(int i=1;i<=m;i++) cout<<TRIE.takeans(skibidi[i],sex[i])<<'\n'; }

컴파일 시 표준 에러 (stderr) 메시지

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen("GAME.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
selling_rna.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen("GAME.OUT","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...