답안 #398958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398958 2021-05-04T23:13:48 Z almothana05 수열 (BOI14_sequence) C++14
0 / 100
3 ms 1800 KB
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std; 
vector<vector<int> >re;
vector<int>num;
int main(){
    int menge , numm , nummer = 0 , erg = 1000000000;
    
    re.push_back(vector<int>(10 , 0));
    re[0][0] = 1;
    for(int i = 1 ; i < 10000 ;i++){
         numm = i;
        re.push_back(vector<int>(10 , 0));

        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 < re.size() ;  i++){
        if(re[i][num[0]] > 0){
            bool ok = 1;
            for(int j = i , k = 0 ; k < num.size() ; k++ , j++){
                if(re[j][num[k]] == 0){
                    ok = 0;
                    break;
                }
            }
            if(ok == 1){
                erg = i;
                break;
            }
        }
    }
    for(int i = 0 ; i < re.size() ;  i++){
        if(re[i][num[num.size() - 1]] > 0){
            bool ok = 1;
            for(int j = i , k = num.size() - 1 ; k >= 0 ; k-- , j++){
                if(re[j][num[k]] == 0){
                    ok = 0;
                    break;
                }
            }
            if(ok == 1){
                int cpm = i + num.size() - 1;
                erg = min(erg  , cpm);
                break;
            }
        }
    }
    cout << erg;
    return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0 ; i < re.size() ;  i++){
      |                     ~~^~~~~~~~~~~
sequence.cpp:33:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for(int j = i , k = 0 ; k < num.size() ; k++ , j++){
      |                                     ~~^~~~~~~~~~~~
sequence.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0 ; i < re.size() ;  i++){
      |                     ~~^~~~~~~~~~~
sequence.cpp:9:24: warning: unused variable 'nummer' [-Wunused-variable]
    9 |     int menge , numm , nummer = 0 , erg = 1000000000;
      |                        ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Runtime error 3 ms 1800 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Runtime error 3 ms 1800 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Runtime error 3 ms 1800 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -