Submission #781390

#TimeUsernameProblemLanguageResultExecution timeMemory
781390mindiyakMutating DNA (IOI21_dna)C++17
0 / 100
26 ms15024 KiB
#include "dna.h" #include <vector> #include <algorithm> #include <iostream> #include <set> #define pb push_back using namespace std; char possible[] = {'A','C','T'}; vector<vector<int>> a_counter; vector<vector<int>> b_counter; vector<int> a_possible_counter; vector<int> b_possible_counter; vector<vector<int>> a_pos; string A,B; void init(string a, string b) { A = a; B = b; vector<int> arr; set<int> arr1; for(int i=0;i<3;i++){ a_counter.pb(arr); b_counter.pb(arr); a_pos.pb(arr); } a_counter[0].pb(0); a_counter[1].pb(0); a_counter[2].pb(0); b_counter[0].pb(0); b_counter[1].pb(0); b_counter[2].pb(0); int ka = 0,kc = 0,kt = 0; for(int i=0;i<a.size();i++){ if(a[i] == 'A'){ ka++; } else if(a[i] == 'C'){ kc++; } else{ kt++; } a_counter[0].pb(ka); a_counter[1].pb(kc); a_counter[2].pb(kt); for(int j=0;j<3;j++){ if(a[i] == possible[j]){ a_pos[j].pb(i); a_possible_counter.pb(j); } } } // for(int i=0;i<a.size();i++){ // cout << a_possible_counter[i] << " "; // }cout << endl; // cout << "A processed "<< endl; ka = 0,kc = 0,kt = 0; for(int i=0;i<b.size();i++){ if(b[i] == 'A'){ ka++; } else if(b[i] == 'C'){ kc++; } else{ kt++; } b_counter[0].pb(ka); b_counter[1].pb(kc); b_counter[2].pb(kt); for(int j=0;j<3;j++){ if(b[i] == possible[j]){ b_possible_counter.pb(j); } } } // cout << "B processed "<< endl; } int get_distance(int x, int y) { for(int i=0;i<3;i++){ cout << possible[i] << " " << (a_counter[i][y+1]-a_counter[i][x]) << " " << (b_counter[i][y+1]-b_counter[i][x]) << endl; if((a_counter[i][y+1]-a_counter[i][x]) != (b_counter[i][y+1]-b_counter[i][x])){ return -1; } } int ans = 0; vector<bool> solved((y-x),false); set<int> a_used; set<int> c_used; set<int> t_used; for(int i=0;i<(y-x);i++){ if(solved[i]) continue; // cout << x << " " << y << endl; // cout << possible[a_possible_counter[x+i]] << " " << possible[b_possible_counter[x+i]] << endl; if(a_possible_counter[x+i] == b_possible_counter[x+i]) continue; int next_char = b_possible_counter[x+i]; // cout << "next_char " << next_char << " " << a_pos.size() << " " << a_pos[next_char].size() << endl; auto from = a_pos[next_char].begin()+x+i; auto to = a_pos[next_char].begin()+y+1; // for(auto j=from;j<to;j++){ // cout << *j << " "; // }cout << endl; auto it = lower_bound(from,to,y); // cout << it-from << " " << to-from << endl; if(it != to){ solved[it - from] = true; } ans ++ ; // cout << endl; } return ans; }

Compilation message (stderr)

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