| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 948313 | ezzzay | DNA 돌연변이 (IOI21_dna) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
std::pmr::string a,b;
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);
std::map<std::pmr::string,int>mp;
mp[s]=1;
std::queue<std::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++){
std::pmr::string tmp=a;
swap(tmp[i],tmp[j]);
if(mp[tmp]==0){
mp[tmp]=w+1;
q.push({tmp,w+1});
}
}
}
}
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:23:14: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
23 | 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:2:
/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:10:12: error: conversion from 'int' to non-scalar type 'std::pmr::string' {aka 'std::__cxx11::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char> >'} requested
10 | #define ff first
| ^
dna.cpp:25:32: note: in expansion of macro 'ff'
25 | std::pmr::string a=q.front().ff;
| ^~
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: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); }
| ^~~~
dna.cpp:37:22: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
37 | 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:2:
/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)
| ~~~~~~~~~~~~~^~~