답안 #38569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38569 2018-01-04T13:28:09 Z bakurits 수열 (BOI14_sequence) C++14
0 / 100
3 ms 2404 KB
#include <iostream>
#include <stdio.h>
#include <vector>

const int N = 1e5 + 10;
const int BIG_N = 1e7;

using namespace std;

int n;
int a[N];

int get_ans(vector <int> req) {
    int ans = 1e9;
    int ls_dig = 0;

    if (req.size() == 1) {
        ans = 0;
        int mask = req[0];
        for (int i = 1; i < 10; i++) {
            if (mask >> i & 1) {
                ans = ans * 10 + i;
                if (mask & 1) {
                    ans = ans * 10;
                    mask--;
                }
            }
        }
        return ans;
    }
    int a1 = 123;

    for (int i = 0; i < 10; i++) {
        int las_dig = i;
        int curId = 0;
        vector <int> cur;
        cur.push_back(0);
        for (int j = 0; j < req.size(); j++) {
            if (las_dig == 0 && j != 0) {
                cur.push_back(0);
                curId++;
            }

            if (req[j] >> las_dig & 1) {
                cur[curId] |= (req[j] - (1 << las_dig));
            } else {
                cur[curId] |= (req[j]);
            }
            las_dig = (las_dig + 1) % 10;
        }
        int cur_ans = 0;
        if (cur != req)
            cur_ans = get_ans(cur);

        if (ans > cur_ans) {
            ans = cur_ans;
            ls_dig = i;
        }

    }

    return ans * 10 + ls_dig;

}

int main() {

    vector <int> req;



    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        req.push_back(1 << a[i]);
    }



    printf("%d", get_ans(req));

}

Compilation message

sequence.cpp: In function 'int get_ans(std::vector<int>)':
sequence.cpp:38:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < req.size(); j++) {
                           ^
sequence.cpp:31:9: warning: unused variable 'a1' [-Wunused-variable]
     int a1 = 123;
         ^
sequence.cpp: In function 'int main()':
sequence.cpp:72:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
sequence.cpp:75:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2404 KB Output is correct
2 Correct 0 ms 2404 KB Output is correct
3 Correct 0 ms 2404 KB Output is correct
4 Incorrect 0 ms 2404 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2404 KB Output is correct
2 Correct 0 ms 2404 KB Output is correct
3 Correct 0 ms 2404 KB Output is correct
4 Incorrect 0 ms 2404 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2404 KB Output is correct
2 Correct 3 ms 2404 KB Output is correct
3 Correct 0 ms 2404 KB Output is correct
4 Incorrect 0 ms 2404 KB Output isn't correct
5 Halted 0 ms 0 KB -