Submission #251913

# Submission time Handle Problem Language Result Execution time Memory
251913 2020-07-23T05:57:57 Z dantoh000 On the Grid (FXCUP4_grid) C++17
0 / 100
0 ms 384 KB
#include <bits/stdc++.h>
#include "grid.h"
using namespace std;
int ct[1005][1005];
int Q[1005];
int done[1005];
int ans[1005];
int query(int N){
    vector<int> res;
    for (int i = 0; i < N; i++) res.push_back(Q[i]);
    return PutDisks(res);
}
vector<int> SortDisks(int N) {

	for (int T = N; T >= 1; T--){
        printf("solving %d now\n",T);
        int id = 0;
        for (int i = 0; i < N; i++) {
            if (done[i]) continue;
            Q[id++] = i;
        }
        for (int i = 0; i < 40; i++){
            random_shuffle(Q,Q+T);
            int X = query(N);
            X -= N;
            for (int j = 0; j < N; j++){
                int Lest = X + (j+1);
                ct[Q[j]][Lest+1] = 1;
            }
        }
        int ANS;
        for (int i = 0; i < N; i++){
            int mxidx = 0;
            for (int j = 0; j <= N; j++){
                //printf("%d ",ct[i][j]);
                if (ct[i][j] == 0) mxidx = j;
            }
           // printf("\n");
            //printf("mxidx for %d = %d\n",i,mxidx);
            if (mxidx == T) {
                ANS = i;
            }
        }
        int i = ANS;
        ans[i] = T;
        Q[T-1] = i;
        done[i] = 1;
	}
	vector<int> ret;
    for (int i = 0; i < N; i++){
        ret.push_back(ans[i]);
    }
	return ret;
}

Compilation message

grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:45:16: warning: 'ANS' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ans[i] = T;
         ~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -