Submission #150719

# Submission time Handle Problem Language Result Execution time Memory
150719 2019-09-01T08:51:41 Z Torat(#3726, Osama_Alkhodairy, mohammedehab2002, mahmoudbadawy) On the Grid (FXCUP4_grid) C++17
43 / 100
10 ms 384 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ans;
int solve(int l,int r,vector<int> p,int cur)
{
	if (l==r)
	{
		ans[p[l]]=cur-(n-l-1);
		return p[l];
	}
	else if ((r-l)%2)
	{
		int mid=(l+r+1)/2;
		vector<int> np=p;
		for (int i=l;i<mid;i++)
		swap(np[i],np[mid+i-l]);
		int tmp=PutDisks(np);
		if (tmp>cur)
		return solve(l,mid-1,np,tmp);
		else
		return solve(l,mid-1,p,cur);
	}
	else
	{
		int mid=(l+r)/2;
		vector<int> np=p;
		for (int i=l;i<mid;i++)
		swap(np[i],np[mid+1+i-l]);
		int tmp=PutDisks(np);
		if (tmp>cur)
		return solve(l,mid-1,np,tmp);
		else
		return solve(l,mid,p,cur);
	}
}
vector<int> SortDisks(int N)
{
	n=N;
	ans.resize(n);
	vector<int> p;
	for (int i=0;i<n;i++)
	p.push_back(i);
	for (int i=0;i<n;i++)
	{
		int tmp=solve(0,n-i-1,p,PutDisks(p));
		p.erase(find(p.begin(),p.end(),tmp));
		bool ok=0;
		for (int j=(int)p.size()-1;j>(int)p.size()-i-1;j--)
		{
			if (ans[tmp]>ans[p[j]])
			{
				p.insert(p.begin()+j+1,tmp);
				ok=1;
				break;
			}
		}
		if (!ok)
		p.insert(p.begin()+n-i-1,tmp);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 9 ms 384 KB Output is correct
13 Correct 9 ms 256 KB Output is correct
14 Correct 8 ms 256 KB Output is correct
15 Correct 8 ms 256 KB Output is correct
16 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 9 ms 384 KB Output is correct
13 Correct 9 ms 256 KB Output is correct
14 Correct 8 ms 256 KB Output is correct
15 Correct 8 ms 256 KB Output is correct
16 Correct 9 ms 256 KB Output is correct
17 Incorrect 10 ms 384 KB Output isn't correct
18 Halted 0 ms 0 KB -