답안 #251914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251914 2020-07-23T06:01:01 Z dantoh000 On the Grid (FXCUP4_grid) C++17
43 / 100
18 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 mn[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 i = 0; i < N; i++){
        mn[i] = 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;
        }
        while (true){
            random_shuffle(Q,Q+T);
            int X = query(N);
            X -= N;
            for (int j = 0; j < N; j++){
                int Lest = X + (j+1);
                mn[Q[j]] = min(mn[Q[j]],Lest);
            }
            int ANS;
            int ansct = 0;
            for (int i = 0; i < N; i++){
               // printf("\n");
                //printf("mxidx for %d = %d\n",i,mxidx);
                if (mn[i] == T) {
                    ANS = i;
                    ansct++;
                }
            }
            if (ansct == 1){
                 int i = ANS;
                ans[i] = T;
                Q[T-1] = i;
                done[i] = 1;
                break;
            }
        }



	}
	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:46:24: warning: 'ANS' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 ans[i] = T;
                 ~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 10 ms 384 KB Output is correct
12 Correct 11 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 9 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 12 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 10 ms 384 KB Output is correct
12 Correct 11 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 9 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 12 ms 256 KB Output is correct
17 Incorrect 18 ms 384 KB Output isn't correct
18 Halted 0 ms 0 KB -