답안 #149456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149456 2019-09-01T06:31:46 Z 20190901(#3597, tongnamuu, jf297, upple1) On the Grid (FXCUP4_grid) C++17
0 / 100
5 ms 256 KB
#include "grid.h"
#define swap(a, b) (a^=b^=a^=b)

std::vector<int> solve(std::vector<int> &a)
{
	std::vector<int> ans(a.size());

	for(int i=0; i<ans.size(); i++)
	{
		ans[a[i]]=i+1;
	}

	return ans;
}
std::vector<int> SortDisks(int N) {
	std::vector<int> res(N), a(N, -1);
	for(int i=0; i<N; i++)
		res[i]=i;
	
	for(int i=N-1; i>=0; i--)
	{
		for(int j=1; j<=i; j++)
		{
			int t=PutDisks(res);
			if(t==N) return solve(res);
			if(t-N==i)
			{
				a[res[0]]=i;
				swap(res[0], res[i]);
				break;
			}

			swap(res[0], res[j]);
		}
	}

	return solve(res);
}

Compilation message

grid.cpp: In function 'std::vector<int> solve(std::vector<int>&)':
grid.cpp:8:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ans.size(); i++)
               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -