Submission #636342

#TimeUsernameProblemLanguageResultExecution timeMemory
636342hy_1Mutating DNA (IOI21_dna)C++17
43 / 100
1594 ms2688 KiB
#include "dna.h" #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <cmath> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <unordered_map> using namespace std; #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ios ios_base::sync_with_stdio(0);cin.tie(0); string s1 , s2; void init(string a, string b) { s1 = a; s2 = b; } int get_distance(int x, int y) { string a,b; a= b = ""; for(int i =x; i<=y; i++){ a += s1[i]; b += s2[i]; } string e = a; string h = b; sort(all(e)); sort(all(h)); if(e != h){ return -1; } if(a == b){ return 0; } if(a.size() == 2){ return 1; }else if(a.size() == 3){ for(int i =0; i <a.size(); i++){ if(a[i] == b[i]){ return 1; } } return 2; } int ans = 0; for(int i =0; i< a.size(); i ++){ if(a[i] != b[i]){ ans++; } } return ans/2; } // int main(){ // string a,b; cin >> a >> b; // init(a,b); // int l,r; cin >> l >> r; // cout << get_distance(l,r) << endl; // return 0; // }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:70:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for(int i =0; i <a.size();  i++){
      |                       ~~^~~~~~~~~
dna.cpp:78:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     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...