답안 #149197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149197 2019-09-01T05:56:41 Z 욱방켜!! (twitch.tv/wookje)(#3584, kig9981, cheetose, jh05013) On the Grid (FXCUP4_grid) C++17
컴파일 오류
0 ms 0 KB
#include "grid.h"

std::vector<int> SortDisks(int N) {
	std::vector<int> ans(N), temp(N);
	for(int i=0;i<N;i++) ans[i]=i;
	for(int i=N-1;i>=0;i--) {
		int X=PutDisks(ans)-N, Y;
		if(X==0) return ans;
		else if(X==i) {
			swap(ans[0],ans[i]);
			continue;
		}
		swap(ans[0],ans[i-X]);
		Y=PutDisks(ans)-N;
		if(Y==0) return ans;
		else if(Y==i) {
			swap(ans[0],ans[i]);
			continue;
		}
		++i;
		for(int j=0;j<i;j++) temp[(j+X)%i]=ans[j];
		for(int j=0;j<i;j++) ans[j]=temp[j];
	}
	return ans;
}

Compilation message

grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:10:4: error: 'swap' was not declared in this scope
    swap(ans[0],ans[i]);
    ^~~~
grid.cpp:10:4: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   'std::swap'
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
In file included from /usr/include/c++/7/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/new:40,
                 from /usr/include/c++/7/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/vector:61,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~
grid.cpp:13:3: error: 'swap' was not declared in this scope
   swap(ans[0],ans[i-X]);
   ^~~~
grid.cpp:13:3: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   'std::swap'
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
In file included from /usr/include/c++/7/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/new:40,
                 from /usr/include/c++/7/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/vector:61,
                 from grid.h:2,
                 from grid.cpp:1:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~