답안 #251915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251915 2020-07-23T06:01:01 Z tqbfjotld On the Grid (FXCUP4_grid) C++17
12 / 100
6 ms 384 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;

int n;
int pos[1005]; ///position of size i
int ans[1005];
vector<int> confirmed;

int wrap(vector<int> v){
    for (int x = confirmed.size()-1; x>=0; x--){
        v.push_back(confirmed[x]);
    }
    vector<int> newv;
    for (auto x : v){
        newv.push_back(x-1);
    }
    int res = PutDisks(newv);
    if (confirmed.size()==n-1) assert(res==n);
    return res-confirmed.size();
}

vector<int> SortDisks(int N) {
    n = N;
    for (int x = N; x>=1; x--){
        vector<int> qu;
        vector<int> rem;
        for (int y = 1; y<=N; y++){
            if (ans[y]) continue;
            rem.push_back(y);
        }
        for (int y : rem){
            qu.clear();
            qu.push_back(y);
            for (int z : rem){
                if (z!=y) qu.push_back(z);
            }
            if (wrap(qu)==x+x-1){
                ans[y] = x;
                confirmed.push_back(y);
                //printf("%d at %d\n",x,y);
                break;
            }
        }

    }

    vector<int> ans2;
    for (int x = 1; x<=n; x++){
        ans2.push_back(ans[x]);
        //printf("push %d\n",ans[x]);
    }
	return ans2;
}


Compilation message

grid.cpp: In function 'int wrap(std::vector<int>)':
grid.cpp:19:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (confirmed.size()==n-1) assert(res==n);
         ~~~~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Incorrect 6 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Incorrect 6 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -