Submission #1040049

#TimeUsernameProblemLanguageResultExecution timeMemory
1040049khanhtbMutating DNA (IOI21_dna)C++17
100 / 100
23 ms8728 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll,ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define sz(a) a.size() #define N 100005 #define fi first #define se second using namespace std; const ll mod = 1e9+7; const int mx = 1e7+10; const ll INF = 1e18; //Road to Expert: 189pts left //Ultimate Target: VOI 202k (4 <= k <= 6) int sum[N][3][3]; int cnt[N][3]; void init(std::string a, std::string b){ for(int i = 1; i <= sz(a); ++i){ for(int j = 0; j < 3; ++j){ cnt[i][j] = cnt[i-1][j]; for(int k = 0; k < 3; ++k) sum[i][j][k] = sum[i-1][j][k]; } int c1 = 0; int c2 = 0; if(a[i-1] == 'A') c1=0; if(a[i-1] == 'T') c1=1; if(a[i-1] == 'C') c1=2; if(b[i-1] == 'A') c2=0; if(b[i-1] == 'T') c2=1; if(b[i-1] == 'C') c2=2; ++sum[i][c1][c2]; ++cnt[i][c1]; --cnt[i][c2]; } } int get_distance(int x, int y){ ++x;++y; if(cnt[y][0]-cnt[x-1][0]) return -1; if(cnt[y][1]-cnt[x-1][1]) return -1; if(cnt[y][2]-cnt[x-1][2]) return -1; int c[3][3]; for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) c[i][j] = sum[y][i][j]-sum[x-1][i][j]; int ans = 0; int tmp; tmp = min(c[0][1],c[1][0]); c[0][1]-=tmp;c[1][0]-=tmp;ans+=tmp; tmp = min(c[0][2],c[2][0]); c[0][2]-=tmp;c[2][0]-=tmp;ans+=tmp; tmp = min(c[2][1],c[1][2]); c[2][1]-=tmp;c[1][2]-=tmp;ans+=tmp; ans+=2*(c[0][1]+c[1][0]); return ans; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 1; i <= sz(a); ++i){
      |                      ^
#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...