Submission #714526

#TimeUsernameProblemLanguageResultExecution timeMemory
714526mseebacherMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define MAXI (int)1e5 #define pb(x) push_back(x) char s1[1e5+5]; char s2[1e5+5]; void init(string x,string y){ for(int i = 0;i<x.length();i++) s1[i] = x[i]; for(int i = 0;i<y.length();i++) s2[i] = y[i]; } int get_distance(int x,int y){ map<char,int> m1,m2; m1.insert({'A',0}); m2.insert({'A',0}); m1.insert({'T',0}); m2.insert({'T',0}); m1.insert({'C',0}); m2.insert({'C',0}); for(int i =x;i<=y;i++){ m1[s1[i]]++; m2[s2[i]]++; } if(m1['A'] != m2['A'] || m1['T'] != m2['T'] || m1['C'] != m2['C']) return -1; int cntr = 0; for(int i = x;i<=y;i++){ if(s1[i] != s2[i]) cntr++; } return (cntr+1)/2; }

Compilation message (stderr)

dna.cpp:8:12: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | char s1[1e5+5];
      |         ~~~^~
dna.cpp:8:12: error: could not convert '(1.0e+5 + (double)5)' from 'double' to 'long unsigned int'
dna.cpp:8:12: error: size of array 's1' has non-integral type 'double'
dna.cpp:9:12: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    9 | char s2[1e5+5];
      |         ~~~^~
dna.cpp:9:12: error: could not convert '(1.0e+5 + (double)5)' from 'double' to 'long unsigned int'
dna.cpp:9:12: error: size of array 's2' has non-integral type 'double'
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0;i<x.length();i++) s1[i] = x[i];
      |                ~^~~~~~~~~~~
dna.cpp:13:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = 0;i<y.length();i++) s2[i] = y[i];
      |                ~^~~~~~~~~~~