Submission #312467

#TimeUsernameProblemLanguageResultExecution timeMemory
312467fivefourthreeoneSelling RNA Strands (JOI16_selling_rna)C++17
0 / 100
41 ms4676 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #define owo(i,a, b) for(auto i=(a);i<(b); ++i) #define uwu(i,a, b) for(auto i=(a)-1; i>=(b); --i) #define senpai push_back #define ttgl pair<int, int> #define ayaya cout<<"ayaya~"<<endl using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update> using ll = long long; using ld = long double; const ll MOD = 998244353; const ll root = 62; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;} ll modInv(ll a){return binpow(a, MOD-2);} const double PI = atan(1); const double eps = 1e-10; const int INF = 0x3f3f3f3f; const int NINF = 0xc0c0c0c0; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const ll NINFLL = 0xc0c0c0c0c0c0c0c0; const int mxN = 100001; __gnu_pbds::gp_hash_table<int, int> mp; int n, m; string s; int hsh(char a) { if(a=='A')return 1; if(a=='C')return 2; if(a=='G')return 3; if(a=='U')return 4; cout<<"REEE\n"; return 5; } int main() { //freopen("file.in", "r", stdin); //freopen("file.out", "w", stdout); mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); cin.tie(0)->sync_with_stdio(0); cin>>n>>m; owo(i, 0, n) { cin>>s; int val = 0; owo(j, 0, s.size()) { val = (val*5 + hsh(s[j]))%MOD; mp[val]++; } } string p, q; owo(i, 0, m) { cin>>p>>q; if(q.size() > p.size()) swap(p, q); bool same = true; int pval = 0; int qval = 0; owo(i, 0, p.size()) { pval = (pval*5 + hsh(p[i]))%MOD; } owo(i, 0, q.size()) { qval = (qval*5 + hsh(q[i]))%MOD; if(p[i]==q[i])continue; same = false; } cout<<(same ? mp[qval] : mp[qval] + mp[pval])<<"\n"; } return 0; }

Compilation message (stderr)

selling_rna.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
selling_rna.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
selling_rna.cpp: In function 'int main()':
selling_rna.cpp:5:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define owo(i,a, b) for(auto i=(a);i<(b); ++i)
      |                                     ^
selling_rna.cpp:49:9: note: in expansion of macro 'owo'
   49 |         owo(j, 0, s.size()) {
      |         ^~~
selling_rna.cpp:5:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define owo(i,a, b) for(auto i=(a);i<(b); ++i)
      |                                     ^
selling_rna.cpp:61:9: note: in expansion of macro 'owo'
   61 |         owo(i, 0, p.size()) {
      |         ^~~
selling_rna.cpp:5:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define owo(i,a, b) for(auto i=(a);i<(b); ++i)
      |                                     ^
selling_rna.cpp:64:9: note: in expansion of macro 'owo'
   64 |         owo(i, 0, q.size()) {
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...