Submission #948305

# Submission time Handle Problem Language Result Execution time Memory
948305 2024-03-18T03:58:04 Z ezzzay Mutating DNA (IOI21_dna) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "dna.h"

#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) {
	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:12:2: error: 'string' was not declared in this scope
   12 |  string s=a.substr(x,y-x+1);
      |  ^~~~~~
dna.cpp:12:2: note: suggested alternatives:
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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 /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dna.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
dna.cpp:13:8: error: expected ';' before 't'
   13 |  string t=b.substr(x,y-x+1);
      |        ^~
      |        ;
dna.cpp:14:2: error: 'map' was not declared in this scope
   14 |  map<string,int>mp;
      |  ^~~
dna.cpp:14: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:1:
/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:1:
/usr/include/c++/10/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
dna.cpp:14:13: error: expected primary-expression before 'int'
   14 |  map<string,int>mp;
      |             ^~~
dna.cpp:15:2: error: 'mp' was not declared in this scope
   15 |  mp[s]=1;
      |  ^~
dna.cpp:15:5: error: 's' was not declared in this scope
   15 |  mp[s]=1;
      |     ^
dna.cpp:16:2: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   16 |  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:1:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
dna.cpp:16:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   16 |  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/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
dna.cpp:16:13: error: expected primary-expression before 'int'
   16 |  queue<pair<int,int>>q;
      |             ^~~
dna.cpp:17:2: error: 'q' was not declared in this scope
   17 |  q.push({s,1});
      |  ^
dna.cpp:19:9: error: expected ';' before 'a'
   19 |   string a=q.front().ff;
      |         ^~
      |         ;
dna.cpp:21:6: error: 'a' was not declared in this scope
   21 |   if(a==t){
      |      ^
dna.cpp:21:9: error: 't' was not declared in this scope
   21 |   if(a==t){
      |         ^
dna.cpp:25:17: error: 'a' was not declared in this scope
   25 |   for(int i=0;i<a.size();i++){
      |                 ^
dna.cpp:27:11: error: expected ';' before 'tmp'
   27 |     string tmp=a;
      |           ^~~~
      |           ;
dna.cpp:28:10: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   28 |     swap(tmp[i],tmp[j]);
      |          ^~~
      |          tm
dna.cpp:28:5: error: 'swap' was not declared in this scope
   28 |     swap(tmp[i],tmp[j]);
      |     ^~~~
dna.cpp:28: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:1:
/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/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:1:
/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); }
      |               ^~~~