Submission #607235

#TimeUsernameProblemLanguageResultExecution timeMemory
607235wiktorlewMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int ile[N][3][2], line[N][3];
int tsf(char c){
	if(c=='A') return 0;
	if(c=='C') return 1;
	if(c=='T') return 2;
}
void init(string a, string b){
	for(int i=0;i<a.length();i++){
		ile[i+1][tsf(a[i])][0]++;
		ile[i+1][tsf(S2[i])][1]++;
		if((a[i]=='A'&&b[i]=='C')||(a[i]=='C'&&b[i]=='A')) line[i+1][0]++;
		if((a[i]=='A'&&b[i]=='T')||(a[i]=='T'&&b[i]=='A')) line[i+1][1]++;
		if((a[i]=='C'&&b[i]=='T')||(a[i]=='T'&&b[i]=='C')) line[i+1][2]++;
		for(int j=0;j<=2;j++){
			ile[i+1][j][0]+=ile[i][j][0];
			ile[i+1][j][1]+=ile[i][j][1];
			line[i+1][j]+=line[i][j];
		}
	}
}
int get_distance(int x, int y){
	x++;
	y++;
	if(ile[b][0][0]-ile[a-1][0][0]!=ile[b][0][1]-ile[a-1][0][1]){
		return -1;
	}
	if(ile[b][1][0]-ile[a-1][1][0]!=ile[b][1][1]-ile[a-1][1][1]){
		return -1;
	}
	if(ile[b][2][0]-ile[a-1][2][0]!=ile[b][2][1]-ile[a-1][2][1]){
		return -1;
	}
	int wynik=0, err=0;
	for(int i=0;i<=2;i++){
		int pom = line[b][i]-line[a-1][i];
		wynik+=pom/2;
		if(pom%2) err++;
	}
	wynik+=(err/3)*2;
	return wynik;
}

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0;i<a.length();i++){
      |              ~^~~~~~~~~~~
dna.cpp:13:16: error: 'S2' was not declared in this scope
   13 |   ile[i+1][tsf(S2[i])][1]++;
      |                ^~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:27:9: error: 'b' was not declared in this scope
   27 |  if(ile[b][0][0]-ile[a-1][0][0]!=ile[b][0][1]-ile[a-1][0][1]){
      |         ^
dna.cpp:27:22: error: 'a' was not declared in this scope
   27 |  if(ile[b][0][0]-ile[a-1][0][0]!=ile[b][0][1]-ile[a-1][0][1]){
      |                      ^
dna.cpp:30:9: error: 'b' was not declared in this scope
   30 |  if(ile[b][1][0]-ile[a-1][1][0]!=ile[b][1][1]-ile[a-1][1][1]){
      |         ^
dna.cpp:30:22: error: 'a' was not declared in this scope
   30 |  if(ile[b][1][0]-ile[a-1][1][0]!=ile[b][1][1]-ile[a-1][1][1]){
      |                      ^
dna.cpp:33:9: error: 'b' was not declared in this scope
   33 |  if(ile[b][2][0]-ile[a-1][2][0]!=ile[b][2][1]-ile[a-1][2][1]){
      |         ^
dna.cpp:33:22: error: 'a' was not declared in this scope
   33 |  if(ile[b][2][0]-ile[a-1][2][0]!=ile[b][2][1]-ile[a-1][2][1]){
      |                      ^
dna.cpp:38:18: error: 'b' was not declared in this scope
   38 |   int pom = line[b][i]-line[a-1][i];
      |                  ^
dna.cpp:38:29: error: 'a' was not declared in this scope
   38 |   int pom = line[b][i]-line[a-1][i];
      |                             ^
dna.cpp: In function 'int tsf(char)':
dna.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^