Submission #1231347

#TimeUsernameProblemLanguageResultExecution timeMemory
1231347yixuan19Mutating DNA (IOI21_dna)C++20
0 / 100
21 ms3172 KiB
#include "dna.h" #include <vector> #include <iostream> #include <unordered_map> #define N 100001 using namespace std; vector <int> s1; vector <int> s2; unordered_map <char,int> convert; bool st2 = true; void init(std::string a, std::string b) { st2 = true; convert['A'] = 0; convert['C'] = 1; convert['T'] = 2; for (int i = 0; i < a.size(); ++i){ if (a[i] == 'C' || b[i] == 'C'){ st2 = false; } s1.push_back(convert[a[i]]); s2.push_back(convert[b[i]]); } } int get_distance(int x, int y) { vector<int>section1; vector<int>section2; int numA = 0; int numT = 0; if (!st2){ cout<<"st 1"<<endl; vector<int> occ1(3,0); vector<int> occ2(3,0); for (int i = x; i <= y; ++i){ occ1[s1[i]]++; section1.push_back(s1[i]); } for (int i = x; i <= y; ++i){ occ2[s2[i]]++; section2.push_back(s2[i]); } if (occ1 != occ2){ return -1; } if (section1 == section2){ return 0; } swap(section1[0], section1[1]); if (section1 == section2){ return 1; } swap(section1[0], section1[1]); swap(section1[1], section1[2]); if (section1 == section2){ return 1; } swap(section1[1], section1[2]); swap(section1[0], section1[2]); if (section1 == section2){ return 1; } swap(section1[0], section1[2]); return 2; }else{ section1.resize(0); section2.resize(0); for (int i = x; i <= y; ++i){ if (s1[i] != s2[i]){ section1.push_back(s1[i]); section2.push_back(s2[i]); } } if (section1.size()%2 != 0){ return -1; }else{ return section1.size()/2; } } }
#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...