답안 #957143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957143 2024-04-03T05:07:27 Z DeltaStruct DNA 돌연변이 (IOI21_dna) C++17
0 / 100
39 ms 9572 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_string(d); acc[i] = {0};
    for (int k(0);k < n;++k) acc[i].emplace_back(acc[i].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 '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;
      |                                                    ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 9572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 9572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -