Submission #1092154

#TimeUsernameProblemLanguageResultExecution timeMemory
1092154user736482Mutating DNA (IOI21_dna)C++17
35 / 100
29 ms6844 KiB
#include <bits/stdc++.h> using namespace std;long long a,b;vector<int>pref[6]; // A/T, T/C, C/A, T/A, C/T, A/C void init(string a,string b){ for(int i=0;i<6;i++) pref[i].push_back(0); for(int i=0;i<a.size();i++){ for(int i=0;i<6;i++) pref[i].push_back(pref[i].back()); if(a[i]=='A' && b[i]=='T') pref[0].back()++; if(a[i]=='T' && b[i]=='C') pref[1].back()++; if(a[i]=='C' && b[i]=='A') pref[2].back()++; if(a[i]=='T' && b[i]=='A') pref[3].back()++; if(a[i]=='C' && b[i]=='T') pref[4].back()++; if(a[i]=='A' && b[i]=='C') pref[5].back()++; }}int get_distance(int x, int y){ x++; y++; int res=0; res+=min(pref[0][y]-pref[0][x-1],pref[3][y]-pref[3][x-1]); res+=min(pref[1][y]-pref[1][x-1],pref[4][y]-pref[4][x-1]); res+=min(pref[2][y]-pref[2][x-1],pref[5][y]-pref[5][x-1]); res+=2*abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]); if(abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]) && abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[0][y]-pref[0][x-1]-pref[3][y]+pref[3][x-1])) return res; else return -1;}

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:3:100: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | void init(string a,string b){    for(int i=0;i<6;i++)        pref[i].push_back(0);    for(int i=0;i<a.size();i++){        for(int i=0;i<6;i++)            pref[i].push_back(pref[i].back());        if(a[i]=='A' && b[i]=='T')            pref[0].back()++;        if(a[i]=='T' && b[i]=='C')            pref[1].back()++;        if(a[i]=='C' && b[i]=='A')            pref[2].back()++;        if(a[i]=='T' && b[i]=='A')            pref[3].back()++;        if(a[i]=='C' && b[i]=='T')            pref[4].back()++;        if(a[i]=='A' && b[i]=='C')            pref[5].back()++;    }}int get_distance(int x, int y){    x++;    y++;    int res=0;    res+=min(pref[0][y]-pref[0][x-1],pref[3][y]-pref[3][x-1]);    res+=min(pref[1][y]-pref[1][x-1],pref[4][y]-pref[4][x-1]);    res+=min(pref[2][y]-pref[2][x-1],pref[5][y]-pref[5][x-1]);    res+=2*abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]);    if(abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]) && abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[0][y]-pref[0][x-1]-pref[3][y]+pref[3][x-1]))        return res;    else        return -1;}
      |                                                                                                   ~^~~~~~~~~
#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...