Submission #440059

#TimeUsernameProblemLanguageResultExecution timeMemory
440059ala2Mutating DNA (IOI21_dna)C++17
0 / 100
52 ms3780 KiB
#include "dna.h" #include <iostream> #include<map> //#include<pair> using namespace std; string s="",c=""; map<pair<char,char>,int>m; void init(string a, string b) { s=a; c=b; int n=s.size(); } int get_distance(int x, int y) { int A=0,C=0,T=0,A2=0,C2=0,T2=0; int ans=0; for(int i=x;i<=y;i++) { if(s[i]!=c[i]) { m[{s[i],c[i]}]++; ans++; } if(s[i]=='A') A++; if(s[i]=='T') T++; if(s[i]=='C') C++; if(c[i]=='A') A2++; if(c[i]=='T') T2++; if(c[i]=='C') C2++; } int we=0; if(A!=A2||C!=C2||T!=T2) return -1; else { int mn=min(m[{'A','T'}],m[{'T','A'}]); ans-=mn*2; we+=mn; m[{'A','T'}]-=mn; m[{'T','A'}]-=mn; mn=min(m[{'A','C'}],m[{'C','A'}]); ans-=mn*2; we+=mn; m[{'A','C'}]-=mn; m[{'C','A'}]-=mn; mn=min(m[{'T','C'}],m[{'C','T'}]); m[{'T','C'}]-=mn; m[{'C','T'}]; ans-=mn*2; we+=mn; int h=m[{'A','T'}]; h=max(h,m[{'T','A'}]); h=max(h,m[{'A','C'}]); h=max(h,m[{'C','A'}]); h=max(h,m[{'T','C'}]); h=max(h,m[{'C','T'}]); we+=h*2; } return we; return 0; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:10:15: warning: unused variable 'n' [-Wunused-variable]
   10 |     c=b;  int n=s.size();
      |               ^
#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...