Submission #437172

# Submission time Handle Problem Language Result Execution time Memory
437172 2021-06-26T01:21:12 Z flashhh Mutating DNA (IOI21_dna) C++17
0 / 100
41 ms 4676 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define fi first
#define se second
#define bp __builtin_popcount
#define nmax 100010
#define pb emplace_back

int getbit(ll x,int y)
{
    return (x>>y)&1;
}
ll getoff(ll x,int y)
{
    return x^((1ll)<<y);
}

using namespace std;

struct node
{
    int AT,AC,TA,TC,CA,CT;
    node() {}
};

int n,q;
string a,b;
node pre[nmax];

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

    for (int i=0;i<n;++i)
    {
        pre[i]=pre[i-1];
        if (a[i]=='A')
        {
            if (b[i]=='C') ++pre[i].AC;
            else if (b[i]=='T') ++pre[i].AT;
        }
        else if (a[i]=='C')
        {
            if (b[i]=='A') ++pre[i].CA;
            else if (b[i]=='T') ++pre[i].CT;
        }
        else if (a[i]=='T')
        {
            if (b[i]=='A') ++pre[i].TA;
            else if (b[i]=='C') ++pre[i].TC;
        }
    }
}
int get_distance(int x,int y)
{
    int AC=pre[y].AC-pre[x-1].AC;
    int AT=pre[y].AT-pre[x-1].AT;

    int CA=pre[y].CA-pre[x-1].CA;
    int CT=pre[y].CT-pre[x-1].CT;
    int TA=pre[y].TA-pre[x-1].TA;
    int TC=pre[y].TC-pre[x-1].TC;

    if (AC+AT!=CA+TA) return -1;
    if (CA+CT!=AC+TC) return -1;
    if (TA+TC!=AT+CT) return -1;


    int ans2=CA+CT;

    if (CA>AC) ans2+=AT;
    else if (CT>TC) ans2+=TA;

	int res=ans2;
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 4676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 4676 KB Output isn't correct
2 Halted 0 ms 0 KB -