# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
107806 | patrikpavic2 | 수열 (BOI14_sequence) | C++17 | 119 ms | 884 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <map>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef set < int > si;
const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int OFF = (1 << 18);
const int LOG = 20;
const double EPS = 1e-9;
const double PI = 3.1415926535;
int n;
vi v;
ll ans(vi msk, int devet){
ll ret = 102345678900000LL;
if(!msk.size()) return 0;
if(msk.size() == 1){
ret = 0;
for(int i = 1;i<10;i++){
if(((1 << i) & msk[0])){
ret = ret * 10LL + i;
if(ret == i && (msk[0] & 1))
ret *= 10LL;
}
}
if((msk[0] & 1) && ret == 0) ret = 10;
return ret;
}
for(int i = 0;i < 9 + devet;i++){
int cur = i, dos = 0, nula = 0;
vi nw;
for(int j = 0;j < msk.size();j++){
int x = msk[j];
if(x & (1 << cur)) x ^= (1 << cur);
dos |= x;
if((dos & 1) && cur == 0) nula = 1;
cur = (cur + 1) % 10;
if(cur == 0 || j == msk.size() - 1) nw.PB(dos), dos = 0;
}
ll nxt = ans(nw, nw.size() > 2 || i < 9) * 10LL + i;
if(nula && !nxt) nxt = 10LL;
ret = min(ret, nxt);
}
return ret;
}
int main(){
scanf("%d", &n);
for(int i = 0;i < n;i++){
int d; scanf("%d", &d);
v.PB((1 << d));
}
ll fin = ans(v, 1);
if(fin == 0) fin = 10LL;
printf("%lld\n", fin);
return 0;
}
컴파일 시 표준 에러 (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... |