Submission #1001981

#TimeUsernameProblemLanguageResultExecution timeMemory
1001981vjudge1Mutating DNA (IOI21_dna)C++17
43 / 100
1568 ms4700 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define pb push_back #define pf push_front #define pi pair<int,int> string a,b; const int MAX = 1e5+10; int n; ll hold[MAX+1]; map<char,int>mtch; void init(string A, string B){ a = A; b = B; for(int i = 1; i <=a.size(); i++){ hold[i] =hold[i-1]; if(A[i-1]!=B[i-1]){ hold[i]++; } } } int get_distance(int x, int y){ // cout << y << " " << x << endl; // cout << hold[y+1] << " " << hold[x] << endl; ll add = hold[y+1]-hold[x] ; string k = a.substr(x,y-x+1); string h= b.substr(x,y-x+1); sort(k.begin(),k.end()); sort(h.begin(),h.end()); if(h!=k){ return -1; } // if(add==0) return 0; return (add+1)/2; } /* int main(){ int n,q ; cin >> n >> q; string a,b; cin >> a >>b; init(a,b); int x,y; while(q--){ cin >> x >>y; cout << get_distance(x,y)<<endl; } } */

Compilation message (stderr)

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