// https://oj.uz/problem/view/balkan11_cmp > p151
#include "cmp.h"
#include <bits/stdc++.h>
using namespace std;
void remember(int n) {
int v[4];
for (int i=0; i<4; i++) {
v[3-i] = n % 10;
n /= 10;
}
bit_set(v[0]+1); // 1-5 se for 0-4
int idx = 6;
for (int i=1; i<4; i++) {
bit_set(v[i]+idx);
idx += 10;
}
}
int compare(int b) {
int v[4];
for (int i=0; i<4; i++) {
v[3-i] = b % 10;
b /= 10;
}
int idx = 1;
for (int i=0; i<4; i++) {
if (bit_get(v[i]+idx)) {
// =
if (i == 0) idx += 5;
else idx += 10;
} else {
if (i == 0) {
if (v[i] >= 2) {
// testa 4 e 3; senão é menor
for (int test=v[i]+1; test <= 4; test++) {
if (bit_get(test+idx)) return -1;
}
return 1;
} else {
for (int test=v[i]-1; test >=0; test--) {
if (bit_get(test+idx)) return 1;
}
return -1;
}
} else {
if (v[i] >= 5) {
for (int test=v[i]+1; test <= 9; test++) {
if (bit_get(test+idx)) return -1;
}
return 1;
} else {
for (int test=v[i]-1; test >= 0; test--) {
if (bit_get(test+idx)) return 1;
}
return -1;
}
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1244 ms |
107024 KB |
Output is partially correct - maxAccess = 12, score = 82 |