Submission #1082322

#TimeUsernameProblemLanguageResultExecution timeMemory
1082322SiliconSquaredMutating DNA (IOI21_dna)C++17
56 / 100
24 ms6272 KiB
#include "dna.h" using namespace std; #include <vector> #include <iostream> vector<int> ca; vector<int> ac; vector<int> ct; vector<int> tc; vector<int> ta; vector<int> at; void init(std::string a, std::string b) { ca.resize(a.size()+1,0); ct.resize(a.size()+1,0); ac.resize(a.size()+1,0); at.resize(a.size()+1,0); ta.resize(a.size()+1,0); tc.resize(a.size()+1,0); for (int i=0;i<a.size();i++){ ca[i+1]=ca[i]; ct[i+1]=ct[i]; at[i+1]=at[i]; ac[i+1]=ac[i]; ta[i+1]=ta[i]; tc[i+1]=tc[i]; if (a[i]=='C'){ if (b[i]=='A'){ ca[i+1]++; }else if (b[i]=='T'){ ct[i+1]++; } }else if (a[i]=='T'){ if (b[i]=='A'){ ta[i+1]++; }else if (b[i]=='C'){ tc[i+1]++; } }else{ if (b[i]=='C'){ ac[i+1]++; }else if (b[i]=='T'){ at[i+1]++; } } } // for (int i:ac){cerr<<i;}cerr<<'\n'; // for (int i:at){cerr<<i;}cerr<<'\n'; // for (int i:ca){cerr<<i;}cerr<<'\n'; // for (int i:ct){cerr<<i;}cerr<<'\n'; // for (int i:ta){cerr<<i;}cerr<<'\n'; // for (int i:tc){cerr<<i;}cerr<<'\n'; } int get_distance(int x, int y) { y++; if (ca[y]-ca[x]+ct[y]-ct[x]!=ac[y]-ac[x]+tc[y]-tc[x]){ return -1; } if (ta[y]-ta[x]+tc[y]-tc[x]!=at[y]-at[x]+ct[y]-ct[x]){ return -1; } if (ac[y]-ac[x]+at[y]-at[x]!=ca[y]-ca[x]+ta[y]-ta[x]){ return -1; } int z=ca[y]-ca[x]+ct[y]-ct[x]+ta[y]-ta[x]+tc[y]-tc[x]+ac[y]-ac[x]+at[y]-at[x]; if (min(ca[y]-ca[x],ac[y]-ac[x])*2+min(ta[y]-ta[x],at[y]-at[x])*2+min(tc[y]-tc[x],ct[y]-ct[x])*2!=z){ z--; } z-=min(ca[y]-ca[x],ac[y]-ac[x]); z-=min(ta[y]-ta[x],at[y]-at[x]); z-=min(tc[y]-tc[x],ct[y]-ct[x]); return z; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i=0;i<a.size();i++){
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...