Submission #510004

#TimeUsernameProblemLanguageResultExecution timeMemory
510004YaserFaisalMutating DNA (IOI21_dna)C++17
0 / 100
35 ms9988 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std ; int ps[100009][20] ; void init ( string a , string b ) { int n = a.size() ; for ( int i = 0 ; i < n ; i++ ) { if ( a[i] == 'A' && b[i] == 'C' ) ps[i+1][1]++ ; if ( a[i] == 'C' && b[i] == 'A' ) ps[i+1][2]++ ; if ( a[i] == 'C' && b[i] == 'T' ) ps[i+1][3]++ ; if ( a[i] == 'T' && b[i] == 'C' ) ps[i+1][4]++ ; if ( a[i] == 'T' && b[i] == 'A' ) ps[i+1][5]++ ; if ( a[i] == 'A' && b[i] == 'T' ) ps[i+1][6]++ ; if ( a[i] == 'A' ) ps[i+1][7]++ ; if ( a[i] == 'C' ) ps[i+1][8]++ ; if ( a[i] == 'T' ) ps[i+1][9]++ ; if ( b[i] == 'A' ) ps[i+1][10]++ ; if ( b[i] == 'C' ) ps[i+1][11]++ ; if ( b[i] == 'T' ) ps[i+1][12]++ ; for ( int j = 1 ; j <= 12 ; j++ ) ps[i+1][j]+=ps[i][j] ; } } // ACT // 1 AC // 2 CA // 3 CT // 4 TC // 5 TA // 6 AT int get_distance ( int x , int y ) { y++ ; for ( int i = 7 ; i <= 9 ; i++ ) { if ( (ps[y][i]-ps[x][i]) != (ps[y][i+3]-ps[x][i+3]) ) return -1 ; } int ans = 0 ; int a = ps[y][1] - ps[x][1] ; int b = ps[y][2] - ps[x][2] ; int c = ps[y][3] - ps[x][3] ; int d = ps[y][4] - ps[x][4] ; int e = ps[y][5] - ps[x][5] ; int f = ps[y][6] - ps[x][6] ; //cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl ; int fi = max(a,b) - min(a,b) ; ans+=min(a,b) ; int s = max(c,d) - min(c,d) ; ans+=min(c,d) ; int t = max(e,f) - min(e,f) ; ans+=min(e,f) ; ans+=2*fi ; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:51:9: warning: unused variable 's' [-Wunused-variable]
   51 |     int s = max(c,d) - min(c,d) ;
      |         ^
dna.cpp:53:9: warning: unused variable 't' [-Wunused-variable]
   53 |     int t = max(e,f) - min(e,f) ;
      |         ^
dna.cpp:55:8: warning: control reaches end of non-void function [-Wreturn-type]
   55 |     ans+=2*fi ;
      |     ~~~^~~~~~
#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...