Submission #977300

# Submission time Handle Problem Language Result Execution time Memory
977300 2024-05-07T17:15:40 Z sstojilkovic19 Mutating DNA (IOI21_dna) C++17
0 / 100
30 ms 6604 KB
#include "dna.h"
#include <bits/stdc++.h>

using namespace std;
string aa, bb;
int n = 100010;

vector< vector<int> >pref(10, vector<int>(n, 0));

void init(std::string a, std::string b) {
    aa=a;
    bb=b;
    n = a.length();

    /*
    0 uk
    1 AT
    2 TA
    3 AC
    4 CA
    5 TC
    6 CT
    TAC
    CTA
    */

    for(int i = 0; i<=6; i++)
    {
        for(int j = 0; j<n; j++)
        {
            pref[i][j]=pref[i][max(0, j-1)];
            if(i==0 && a[j]!=b[j])pref[i][j]++;
            else if(i==1 && a[j]=='A' && b[j]=='T')pref[i][j]++;
            else if(i==2 && a[j]=='T' && b[j]=='A')pref[i][j]++;
            else if(i==3 && a[j]=='A' && b[j]=='C')pref[i][j]++;
            else if(i==4 && a[j]=='C' && b[j]=='A')pref[i][j]++;
            else if(i==5 && a[j]=='T' && b[j]=='C')pref[i][j]++;
            else if(i==6 && a[j]=='C' && b[j]=='T')pref[i][j]++;
        }
    }
}

int get_distance(int x, int y)
{
	int a=0;
	if(x>0)a=x-1;
	int ans = pref[0][y]-pref[0][a]-1;
	ans -= min(pref[1][y]-pref[1][a], pref[2][y]-pref[2][a]);
	ans -= min(pref[3][y]-pref[3][a], pref[4][y]-pref[4][a]);
	ans -= min(pref[5][y]-pref[5][a], pref[6][y]-pref[6][a]);

	if(ans==0)
    {
        for(int i = x; i<=y; i++)
        {
            if(aa[i]!=bb[i])
            {
                ans++;
                break;
            }

        }
    }

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 6604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 6604 KB Output isn't correct
2 Halted 0 ms 0 KB -