# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1034242 |
2024-07-25T11:12:01 Z |
vjudge1 |
cmp (balkan11_cmp) |
C++17 |
|
1139 ms |
82576 KB |
#include "cmp.h"
#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
int a[4096], b[2][64];
void remember(int n) {
for (int i = 0; i < 4096; i++) {
a[i] = -2;
}
for (int i = 0; i < 64; i++) {
b[0][i] = inf;
b[1][i] = -inf;
}
int x = __builtin_popcount(n);
if (x <= 1 + 12-x) {
for (int i = 0; i <= 11; i++) {
if ((n >> i) & 1) bit_set(i+1);
}
}
else {
bit_set(13);
for (int i = 0; i <= 11; i++) {
if (!((n >> i) & 1)) bit_set(i+1);
}
}
}
void update(int x, int y) {
a[x] = y;
b[0][x/64] = min(b[0][x/64], y);
b[1][x/64] = max(b[1][x/64], y);
}
int compare(int n) {
/*
if (n && a[n-1] == -1 && n+1 < 4096 && a[n+1] == 1) {
update(n, 0);
return 0;
}
for (int i = 0; i < n; i++) {
if (i%64 == 0 && i+63 < n) {
if (b[1][i/64] > -1) {
update(n, 1);
return 1;
}
i += 63;
continue;
}
if (a[i] == -2) continue;
else if (a[i] > -1) {
update(n, 1);
return 1;
}
}
for (int i = n+1; i < 4096; i++) {
if (i%64 == 0) {
if (b[0][i/64] < 1) {
update(n, -1);
return -1;
}
i += 63;
continue;
}
if (a[i] == -2) continue;
else if (a[i] < 1) {
update(n, -1);
return -1;
}
}
*/
int inv = bit_get(13);
for (int i = 11; i >= 0; i--) {
int x = bit_get(i+1);
if (inv) x = !x;
int y = (n >> i) & 1;
if (x > y) {
update(n, -1);
return -1;
}
else if (x < y) {
update(n, 1);
return 1;
}
}
update(n, 0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1139 ms |
82576 KB |
Output is partially correct - maxAccess = 19, score = 19 |