Submission #1255799

#TimeUsernameProblemLanguageResultExecution timeMemory
1255799robijoyMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
// #include <bits/stdc++.h> #include "dna.h" using namespace std; string A,B; int n; void init(std::string a, std::string b) { A = a; B = b; n = a.size(); } int get_distance(int x, int y) { if(x == y) { if(A[x]!=B[y]) { return -1; }else { return 0; } } int ans = -1; string ro = A.substr(x,y-x+1); string ra = B.substr(x,y-x+1); string roo = ro; string raa = ra; sort(roo.begin(), roo.end()); sort(raa.begin(), raa.end()); if(roo == raa) { int cnt = 0; for (int i = 0; i < ro.size(); ++i) { if(ro[i] != ra[i]) cnt++; } ans = cnt/2; } return ans; } // int main() { // init("ATATAT","ATTATA"); // cout<<get_distance(0,1)<<endl; // }// #include <bits/stdc++.h> #include "dna.h" using namespace std; string A,B; int n; void init(std::string a, std::string b) { A = a; B = b; n = a.size(); } int get_distance(int x, int y) { if(x == y) { if(A[x]!=B[y]) { return -1; }else { return 0; } } int ans = -1; string ro = A.substr(x,y-x+1); string ra = B.substr(x,y-x+1); string roo = ro; string raa = ra; sort(roo.begin(), roo.end()); sort(raa.begin(), raa.end()); if(roo == raa) { int cnt = 0; for (int i = 0; i < ro.size(); ++i) { if(ro[i] != ra[i]) cnt++; } ans = cnt/2; } return ans; } // int main() { // init("ATATAT","ATTATA"); // cout<<get_distance(0,1)<<endl; // }

Compilation message (stderr)

dna.cpp:49:8: error: redefinition of 'std::string A'
   49 | string A,B;
      |        ^
dna.cpp:5:8: note: 'std::string A' previously declared here
    5 | string A,B;
      |        ^
dna.cpp:49:10: error: redefinition of 'std::string B'
   49 | string A,B;
      |          ^
dna.cpp:5:10: note: 'std::string B' previously declared here
    5 | string A,B;
      |          ^
dna.cpp:50:5: error: redefinition of 'int n'
   50 | int n;
      |     ^
dna.cpp:6:5: note: 'int n' previously declared here
    6 | int n;
      |     ^
dna.cpp:52:6: error: redefinition of 'void init(std::string, std::string)'
   52 | void init(std::string a, std::string b) {
      |      ^~~~
dna.cpp:8:6: note: 'void init(std::string, std::string)' previously defined here
    8 | void init(std::string a, std::string b) {
      |      ^~~~
dna.cpp:58:5: error: redefinition of 'int get_distance(int, int)'
   58 | int get_distance(int x, int y) {
      |     ^~~~~~~~~~~~
dna.cpp:14:5: note: 'int get_distance(int, int)' previously defined here
   14 | int get_distance(int x, int y) {
      |     ^~~~~~~~~~~~