Submission #734825

# Submission time Handle Problem Language Result Execution time Memory
734825 2023-05-03T06:38:32 Z rahidilbayramli Mutating DNA (IOI21_dna) C++17
0 / 100
35 ms 13556 KB
#include "dna.h"
using namespace std;
long long hsh[85], tbl[5][5][100005], cnt[5][100005], t[5][5], i, j, k;
void init(string a, string b)
{
    hsh['A'] = 1;
    hsh['B'] = 2;
    hsh['C'] = 3;
    a = ' ' + a;
    b = ' ' + b;
    for(i = 1; i < a.size(); i++)
    {
        cnt[hsh[a[i]]][i]++, cnt[hsh[b[i]]][i]--;
        for(j = 1; j <= 3; j++)
            cnt[j][i] += cnt[j][i-1];
        for(j = 1; j <= 3; j++)
        {
            for(int k = 1; k <= 3; k++)
                tbl[j][k][i] = tbl[j][k][i-1];
        }
    }
    tbl[hsh[a[i]]][hsh[b[i]]][i]++;
}
int get_distance(int x, int y)
{
    x++, y++;
    for(i = 1; i <= 3; i++)
    {
        if(cnt[i][y] != cnt[i][x-1])    return -1;
    }
    for(i = 3; i <= 3; i++)
    {
        for(int j = 1; j <= 3; j++)
            t[i][j] = tbl[i][j][y] - tbl[i][j][x-1];
    }
    long long res = 0, temp;
    temp = min(t[1][2], t[2][1]);
    res += temp;
    t[1][2] -= temp;
    t[2][1] -= temp;
    temp = min(t[1][3], t[3][1]);
    res += temp;
    res += temp;
    temp = min(t[2][3], t[3][2]);
    res += temp;
    return res + max(t[1][2], t[2][1]) * 2;
}

Compilation message

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(i = 1; i < a.size(); i++)
      |                ~~^~~~~~~~~~
dna.cpp:13:21: warning: array subscript has type 'char' [-Wchar-subscripts]
   13 |         cnt[hsh[a[i]]][i]++, cnt[hsh[b[i]]][i]--;
      |                     ^
dna.cpp:13:42: warning: array subscript has type 'char' [-Wchar-subscripts]
   13 |         cnt[hsh[a[i]]][i]++, cnt[hsh[b[i]]][i]--;
      |                                          ^
dna.cpp:22:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   22 |     tbl[hsh[a[i]]][hsh[b[i]]][i]++;
      |                 ^
dna.cpp:22:28: warning: array subscript has type 'char' [-Wchar-subscripts]
   22 |     tbl[hsh[a[i]]][hsh[b[i]]][i]++;
      |                            ^
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 13556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 13556 KB Output isn't correct
2 Halted 0 ms 0 KB -