Submission #957142

# Submission time Handle Problem Language Result Execution time Memory
957142 2024-04-03T05:06:41 Z DeltaStruct Mutating DNA (IOI21_dna) C++17
Compilation error
0 ms 0 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

string x,y,u="ACT"; int n; map<string,vector<int>> acc;
void init(string a,string b){
  x = a,y = b,n = a.size();
  for (auto c:u) for (auto d:u) if (c!=d){
    string i = to_string(c)+to_strind(d); acc[i] = {0};
    for (int k(0);k < n;++k) acc[i].emplace_back(acc.back()+(x[k]==c&&y[k]==d));
  }
}

int get_distance(int l,int r){
  ++r;
  auto sb = [&acc,&l,&r](string s,string t){ return (acc[s][r]-acc[s][l])-(acc[t][r]-acc[t][l]); }
  if (sb("AC","CA")!=sb("CT","TC")||sb("AC","CA")!=sb("TA","AT")) return -1;
  int res = abs(sb("AC","CA"))*2;
  for (int i(0);i < 3;++i) for (int k(0);k < 3;++k){
    string s = to_string(u[i])+to_string(u[k]),t = to_string(u[k])+to_string(u[i]);
    res += min(acc[s][r]-acc[s][l],acc[t][r]-acc[t][l]);
  }
  return res;
}

Compilation message

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:29: error: 'to_strind' was not declared in this scope
    9 |     string i = to_string(c)+to_strind(d); acc[i] = {0};
      |                             ^~~~~~~~~
dna.cpp:10:54: error: 'class std::map<std::__cxx11::basic_string<char>, std::vector<int> >' has no member named 'back'
   10 |     for (int k(0);k < n;++k) acc[i].emplace_back(acc.back()+(x[k]==c&&y[k]==d));
      |                                                      ^~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:16:15: warning: capture of variable 'acc' with non-automatic storage duration
   16 |   auto sb = [&acc,&l,&r](string s,string t){ return (acc[s][r]-acc[s][l])-(acc[t][r]-acc[t][l]); }
      |               ^~~
dna.cpp:5:52: note: 'std::map<std::__cxx11::basic_string<char>, std::vector<int> > acc' declared here
    5 | string x,y,u="ACT"; int n; map<string,vector<int>> acc;
      |                                                    ^~~
dna.cpp:17:3: error: expected ',' or ';' before 'if'
   17 |   if (sb("AC","CA")!=sb("CT","TC")||sb("AC","CA")!=sb("TA","AT")) return -1;
      |   ^~