Submission #542258

#TimeUsernameProblemLanguageResultExecution timeMemory
542258apocryphal44Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include<string> #include<iostream> using namespace std; string s_a, s_b; class DNA{ public: string str_{}; int A_count{0}, T_count{0}, C_count{0}; DNA (string a) : str_(a) { for (auto i: str_){ switch((int)i){ case 65: this->A_count++; break; case 67: this->C_count++; break; case 84: this->T_count++; break; default: throw; }}} }; void init(string a, string b){ s_a = a; s_b = b; } int get_distance(int x, int y){ // Validity Check if (x>y) throw; if (x<0 or y <0) throw; // Feasible Check const int len{y-x+1}; DNA a_sub{s_a.substr((long long unsigned int)x, (long long unsigned int)len)}; DNA b_sub{s_b.substr((long long unsigned int)x, (long long unsigned int)len)}; if ((a_sub.A_count != b_sub.A_count) or (a_sub.C_count != b_sub.C_count) or (a_sub.T_count != b_sub.T_count)) return -1; // Greedy Algorithm int r{0}, i{0}; for( auto j : a_sub.str_){ char b_i = b_sub.str_.at((long long unsigned int)i); if (b_i != j) { for (int k{i+1}; k<len; k++){ if (b_sub.str_.at((long long unsigned int)k) == j) { b_sub.str_[(long long unsigned int)i] = j; b_sub.str_[(long long unsigned int)k] = b_i; r++; break; } } } i++; } return r; } int main(){ int n,q; string a,b; cin >> n >>q; cin >> a; cin >> b; init(a,b); int x,y; while(q){ cin >> x >> y; get_distance(x,y); q--; } } /* int main(){ string str1, str2; int a,b; cin >> str1 >> str2; init(str1, str2); cin >> a >> b; cout << get_distance(a,b); return 0; }*/

Compilation message (stderr)

/usr/bin/ld: /tmp/ccss3BSO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccTfCLFN.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status