Submission #716418

#TimeUsernameProblemLanguageResultExecution timeMemory
716418kidlinMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int val = 1e11+5; string s,t; int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val]; void init(string a,string b){ s='#' + a,t= '#' + b; for(int i=1;i<s.size();i++) { if(s[i]=='T') T0[i]++; T0[i]+=T0[i-1]; if(s[i]=='C') C0[i]++; C0[i]+=C0[i-1]; if(s[i]=='A') A0[i]++; A0[i]+=A0[i-1]; if(t[i]=='T') T1[i]++; T1[i]+=T1[i-1]; if(t[i]=='C') C1[i]++; C1[i]+=C1[i-1]; if(t[i]=='A') A1[i]++; A1[i]+=A1[i-1]; if(t[i] != s[i]) res[i] ++; res[i] += res[i-1]; } } int get_distance(int x, int y) { x ++, y ++; int f = T0[y]-T0[x-1]; int f1 = T1[y]-T1[x-1]; int g = C0[y]-C0[x-1]; int g1 = C1[y]-C1[x-1]; int d = A0[y]-A0[x-1]; int d1 = A1[y]-A1[x-1]; if(f!=f1 || g!=g1 || d!=d1) return -1; return (res[y]-res[x-1]+1)/2; }

Compilation message (stderr)

dna.cpp:3:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.00000000005e+11' to '2147483647' [-Woverflow]
    3 | const int val = 1e11+5;
      |                 ~~~~^~
dna.cpp:5:8: error: size of array 'T0' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |        ^~~
dna.cpp:5:16: error: size of array 'C0' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                ^~~
dna.cpp:5:24: error: size of array 'A0' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                        ^~~
dna.cpp:5:32: error: size of array 'T1' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                                ^~~
dna.cpp:5:40: error: size of array 'A1' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                                        ^~~
dna.cpp:5:48: error: size of array 'C1' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                                                ^~~
dna.cpp:5:58: error: size of array 'res' exceeds maximum object size '9223372036854775807'
    5 | int T0[val],C0[val],A0[val],T1[val],A1[val],C1[val], res[val];
      |                                                          ^~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=1;i<s.size();i++)
      |                 ~^~~~~~~~~