| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 843551 | manizare | Sequence (BOI14_sequence) | C++14 | 320 ms | 2640 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h> 
 
#define int long long 
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int> 
#define int long long
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int maxn = 1e5 + 10 , inf = 1e17 + 10  ;
int a10[18] ;
int dfs(vector <int> vec,  int ok){
  if(vec.size() == 0)return ok ;
  if(vec.size() == 1){
    if(vec[0] == 0){
      return ok ;
    }
    if(vec[0] == 1){
      return 10 ;
    }
    vector <int> vj ;
    for(int i = 0 ;i < 10 ; i++){
      if(vec[0]>>i&1){
        vj.pb(i) ; 
      }
    }
    if(vj[0] == 0){
      swap(vj[0], vj[1]);
    }
    int ans = 0;
    for(int i= 0  ; i < vj.size() ; i++){
      ans *= 10 ;
      ans += vj[i] ;
    }
    return ans ; 
  }
  int ans = inf ; 
  for(int i = 0 ; i < 10 ; i++){
    int t =0  , k = i ;
    vector <int> vec2 ;
    for(int j = 0;  j < vec.size() ; j++){
      if(k == 10){
        k =0 ; 
        vec2.pb(t) ;
        t = 0 ;
      }
      if(vec[j]>>k&1){
        vec[j] -= (1<<k) ;
        t |=  vec[j] ;
        vec[j]+= (1<<k) ;
      }else{
        t |= vec[j] ; 
      }
      k++;
    }
    vec2.pb(t) ;
    if(vec2 == vec && ok == (i==0)){
      continue ;
    }
    ans = min(ans ,  dfs(vec2 , (i==0) * (vec[0]%2)) * 10 + i )  ;
  }  
  return ans ; 
}
signed main(){
  ios::sync_with_stdio(false); cin.tie(0) ;  
  vector<int>vec ; 
  int n ;cin >> n ;
  for(int i = 1; i <= n; i++){
    int x;
    cin >> x ;
    vec.pb((1<<x)) ;
  } 
   cout << dfs(vec , 1) ;
}
/*
4 7 8 9 1 
4 7 0 0 0
4 8 0 0 0 
4 7 8 0 1 
*/
컴파일 시 표준 에러 (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... | ||||
