Submission #1070248

#TimeUsernameProblemLanguageResultExecution timeMemory
1070248hasan2006Mutating DNA (IOI21_dna)C++17
56 / 100
41 ms15132 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 2e5 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N] , c[N][4] , d[N][4]; int ok(int x , int y){ int s = 0, j; for(j = 1; j <= 3; j++) s += ((d[y][j] - (x > 0 ? d[x - 1][j] : 0)) != (c[y][j] - (x > 0 ? c[x - 1][j] : 0))); return (s == 0); } int get_distance(int x , int y){ if(ok(x , y)) return ((dp[y] - (x > 0 ? dp[x - 1] : 0)) + 1) / 2 ; else return -1; } void init(string a, string b){ map<char,int>mp; mp['A'] = 1; mp['C'] = 2; mp['T'] = 3; for(int i = 0; i < a.size(); i++){ if(i) for(int j = 1; j <= 3; j++) dp[i] = dp[i - 1] , c[i][j] = c[i - 1][j] , d[i][j] = d[i - 1][j]; c[i][mp[a[i]]]++; d[i][mp[b[i]]]++; dp[i] += (a[i] != b[i]); } } // Author : حسن

Compilation message (stderr)

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