Submission #948308

# Submission time Handle Problem Language Result Execution time Memory
948308 2024-03-18T03:59:07 Z ezzzay Mutating DNA (IOI21_dna) C++17
Compilation error
0 ms 0 KB
#include "dna.h"
#include<bits/stdc++.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<utility>
#include<queue>
#include<map>
#define ff first
#define ss second
#define pb push_back

void init(std::string a, std::string b) {
}

int get_distance(int x, int y) {
	std::pmr::string s=a.substr(x,y-x+1);
	std::pmr::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()){
		std::pmr::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:18:21: error: 'a' was not declared in this scope
   18 |  std::pmr::string s=a.substr(x,y-x+1);
      |                     ^
dna.cpp:19:21: error: 'b' was not declared in this scope
   19 |  std::pmr::string t=b.substr(x,y-x+1);
      |                     ^
dna.cpp:20:2: error: 'map' was not declared in this scope
   20 |  map<string,int>mp;
      |  ^~~
dna.cpp:20:2: note: suggested alternatives:
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from dna.cpp:2:
/usr/include/c++/10/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
dna.cpp:20:6: error: 'string' was not declared in this scope
   20 |  map<string,int>mp;
      |      ^~~~~~
dna.cpp:20:6: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
dna.cpp:20:13: error: expected primary-expression before 'int'
   20 |  map<string,int>mp;
      |             ^~~
dna.cpp:21:2: error: 'mp' was not declared in this scope
   21 |  mp[s]=1;
      |  ^~
dna.cpp:22:2: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   22 |  queue<pair<int,int>>q;
      |  ^~~~~
      |  std::queue
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:2:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
dna.cpp:22:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   22 |  queue<pair<int,int>>q;
      |        ^~~~
      |        std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
dna.cpp:22:13: error: expected primary-expression before 'int'
   22 |  queue<pair<int,int>>q;
      |             ^~~
dna.cpp:23:2: error: 'q' was not declared in this scope
   23 |  q.push({s,1});
      |  ^
dna.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
dna.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    for(int j=0;j<a.size();j++){
      |                ~^~~~~~~~~
dna.cpp:33:11: error: expected ';' before 'tmp'
   33 |     string tmp=a;
      |           ^~~~
      |           ;
dna.cpp:34:10: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   34 |     swap(tmp[i],tmp[j]);
      |          ^~~
      |          tm
dna.cpp:34:5: error: 'swap' was not declared in this scope
   34 |     swap(tmp[i],tmp[j]);
      |     ^~~~
dna.cpp:34:5: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from dna.cpp:2:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/string:41,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/filesystem:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from dna.cpp:2:
/usr/include/c++/10/bits/fs_path.h:658:15: note:   'std::filesystem::__cxx11::swap'
  658 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~