| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 38582 | bakurits | 수열 (BOI14_sequence) | C++14 | 179 ms | 3388 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
long long get_ans(vector <int> req) {
    long long ans = 1e17;
    int ls_dig = 0;
    while (req.size() > 0 && req[req.size() - 1] == 0)
        req.pop_back();
    if (req.size() == 0) return 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--;
                }
            }
        }
        if (mask & 1)
            return 10;
        return ans;
    }
    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 = 1e18;
        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));
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
