Submission #948319

# Submission time Handle Problem Language Result Execution time Memory
948319 2024-03-18T04:05:39 Z ezzzay Mutating DNA (IOI21_dna) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<char, char>;
 
string a, b;
int n;
vector<char> x = {'A', 'C', 'T'};
vector<int> pa, pc, pt, pa1, pc1, pt1;
map<pii, vector<int>> pr;
 
void init(string as, string bs){
    a = as; b = bs;
    n = (int) a.length();
    pa.resize(n + 1);
    pc.resize(n + 1);
    pt.resize(n + 1);
    pa1.resize(n + 1);
    pc1.resize(n + 1);
    pt1.resize(n + 1);
    for (int i = 1; i <= n; i++){
        pa[i] = pa[i - 1] + (a[i] == 'A');
        pc[i] = pc[i - 1] + (a[i] == 'C');
        pt[i] = pt[i - 1] + (a[i] == 'T');
        pa1[i] = pa1[i - 1] + (b[i] == 'A');
        pc1[i] = pc1[i - 1] + (b[i] == 'C');
        pt1[i] = pt1[i - 1] + (b[i] == 'T');
    }
    for (char i1: x){
        for (char i2: x){
            if (i1 == i2) continue;
            pr[{i1, i2}].resize(n + 1);
            for (int i = 1; i <= n; i++){
                pr[{i1, i2}][i] = pr[{i1, i2}][i - 1] + (a[i] == i1 && b[i] == i2);
            }
        }
    }
}
 
int get_distance(int x, int y){
    string s=a.substr(x,y-x+1);
	string t=b.substr(x,y-x+1);
	map<string,int>mp;
	mp[s]=1;
	queue<pair<int,int>>q;
	q.push({s,1});
	while(!q.empty()){
		string a=q.front().ff;
		int w=q.front().ss;
		if(a==t){
			return w-1;
		}
		q.pop();
		for(int i=0;i<a.size();i++){
			for(int j=0;j<a.size();j++){
				string tmp=a;
				swap(tmp[i],tmp[j]);
				if(mp[tmp]==0){
					mp[tmp]=w+1;
					q.push({tmp,w+1});
				}
			}
		}
	}
	return -1;
}

Compilation message

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:46:14: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   46 |  q.push({s,1});
      |              ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
dna.cpp:48:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ff'
   48 |   string a=q.front().ff;
      |                      ^~
dna.cpp:49:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ss'
   49 |   int w=q.front().ss;
      |                   ^~
dna.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
dna.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |    for(int j=0;j<a.size();j++){
      |                ~^~~~~~~~~
dna.cpp:60:22: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   60 |      q.push({tmp,w+1});
      |                      ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~