Submission #398968

# Submission time Handle Problem Language Result Execution time Memory
398968 2021-05-04T23:23:06 Z almothana05 Sequence (BOI14_sequence) C++14
0 / 100
18 ms 14668 KB
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std; 
vector<vector<int> >re(100000 , vector<int>(10 , 0));
vector<int>num;
int main(){
    int menge , numm , nummer = 0 , erg = 100000;
    
    re[0][0] = 1;
    for(int i = 1 ; i < 100000 ;i++){
         numm = i;
        while(numm > 0){
            re[i][numm % 10]++;
            if(numm == 0){
                break;
            }
            numm/=10;
        }
    }
    cin >> menge;
    for(int i = 0 ; i < menge ; i++){
        cin >> numm ;
        num.push_back(numm);
    }
    for(int i = 0 ; i < 100000 ;  i++){
        bool ok = 1;
        for(int j = i , k = 0 ; k < menge ; k++ , j++){
            if(re[j][num[k]] == 0){
                ok = 0;
                break;
            }
        }
        if(ok == 1){
            erg = i;
            break;
        }
    }
    for(int i = 0 ; i < 100000 ;  i++){
        bool ok = 1;
        for(int j = i , k = menge - 1 ; k >= 0 ; k-- , j++){
            if(re[j][num[k]] == 0){
                ok = 0;
                break;
            }
        }
        if(ok == 1){
            int cpm = i + menge - 1;
            erg = min(erg  , cpm);
            break;
        }
        
    }
    cout << erg;
    return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:9:24: warning: unused variable 'nummer' [-Wunused-variable]
    9 |     int menge , numm , nummer = 0 , erg = 100000;
      |                        ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 7296 KB Output is correct
2 Correct 13 ms 7244 KB Output is correct
3 Runtime error 18 ms 14668 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 7308 KB Output is correct
2 Correct 13 ms 7244 KB Output is correct
3 Runtime error 18 ms 14636 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 7348 KB Output is correct
2 Correct 12 ms 7356 KB Output is correct
3 Runtime error 18 ms 14644 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -