Submission #529187

#TimeUsernameProblemLanguageResultExecution timeMemory
529187Icebear16Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h"
int n,q;
string s,c;
void init(std::string a, std::string b) {
	s=a,c=b;
	while(q--){
    	int x,y;
		get_distance(x,y);
	}
}
int get_distance(int x, int y) {
	int h1,h2,l1,l2,k1,k2;
	for(int i=x;i<=y;i++){
		if(s[i]=='A'){
			h1++;
		}else if(s[i]=='T'){
			l1++;
		}else if(s[i]=='C'){
			k1++;
		}
		if(c[i]=='A'){
			h2++;
		}else if(c[i]=='T'){
			l2++;
		}else if(c[i]=='C'){
			k2++;
		}
	}
	if(h1==h2 && l1==l2 && k1==k2){
		int j=0;
		for(int i=x;i<=y;i++){
			if(s[i]!=c[i]){
				j+=1;
			}
		}
		if(j%2==1){
			j+=1;
		}
		return j/2;
	}else{
		return -1;
	}
}

Compilation message (stderr)

dna.cpp:3:1: error: 'string' does not name a type; did you mean 'stdin'?
    3 | string s,c;
      | ^~~~~~
      | stdin
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:5:2: error: 's' was not declared in this scope
    5 |  s=a,c=b;
      |  ^
dna.cpp:5:6: error: 'c' was not declared in this scope
    5 |  s=a,c=b;
      |      ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:14:6: error: 's' was not declared in this scope
   14 |   if(s[i]=='A'){
      |      ^
dna.cpp:21:6: error: 'c' was not declared in this scope
   21 |   if(c[i]=='A'){
      |      ^
dna.cpp:32:7: error: 's' was not declared in this scope
   32 |    if(s[i]!=c[i]){
      |       ^
dna.cpp:32:13: error: 'c' was not declared in this scope
   32 |    if(s[i]!=c[i]){
      |             ^