Submission #527512

# Submission time Handle Problem Language Result Execution time Memory
527512 2022-02-17T14:24:07 Z beepbeepsheep On the Grid (FXCUP4_grid) C++17
0 / 100
1 ms 204 KB
#include "grid.h"

#include <bits/stdc++.h>
using namespace std;
#define ll long long
std::vector<int> SortDisks(int n) {
	int X = PutDisks(std::vector<int>{0,2,3,1});
	vector<int> v,ans(n);
	short chk[n];
	memset(chk,-1,sizeof(chk));
	for (int i=0;i<n;i++){
        v.push_back(i);
	}
	ll a=PutDisks(v),b;
	vector<int> w;
	while (v.size()){
        w.clear();
        ll t=v.back(),p=0;
        for (int i=v.size()-1;i>0;i--) swap(v[i],v[i-1]);
        for (int i=0;i<n;i++){
            if (chk[i]!=-1) w.push_back(chk[i]);
            else w.push_back(v[p++]);
        }
        b=PutDisks(w);
        if (b>a-1){
            t=v[0];
            ans[t]=b-(n-1);
            chk[ans[t]-1]=t;
            for (int i=0;i<v.size()-1;i++) swap(v[i],v[i+1]);
            v.pop_back();
        } else a=b;
	}
	return ans;
}

Compilation message

grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for (int i=0;i<v.size()-1;i++) swap(v[i],v[i+1]);
      |                          ~^~~~~~~~~~~
grid.cpp:7:6: warning: unused variable 'X' [-Wunused-variable]
    7 |  int X = PutDisks(std::vector<int>{0,2,3,1});
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -