Submission #118715

# Submission time Handle Problem Language Result Execution time Memory
118715 2019-06-19T13:56:07 Z songc Sequence (BOI14_sequence) C++14
0 / 100
48 ms 384 KB
#include <bits/stdc++.h>
#define INF 1234567890123456ll
using namespace std;
typedef long long LL;

int N;

LL f(vector<int> A, int lv){
    if (lv > 15) return INF;
    LL ans = INF;
    if (A.size() == 1){
        LL ret=0;
        if (A[0] == 1) return 10;
        for (int i=1; i<10; i++) if (A[0] & (1<<i)){
            ret = ret*10 + i;
            if (A[0] & 1) ret = ret*10, A[0] ^= 1;
        }
        return ret;
    }

    for (int i=0; i<10; i++){
        vector<int> B((i+A.size())/10+1);
        for (int j=0; j<(int)A.size(); j++) B[(i+j)/10] |= A[j] & ~(1<<((i+j)%10));
        if (A == B) continue;
        LL ret = f(B, lv+1);
        if (ret == INF) continue;
        if (ret == 0 && i == 0) ans = min(ans, 10ll);
        else ans = min(ans, ret*10 + i);
    }
    return ans;
}

int main(){
    scanf("%d", &N);
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        scanf("%d", &A[i]);
        A[i] = 1 << A[i];
    }
    printf("%lld\n", f(A, 1));
    return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
sequence.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 48 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -