# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415214 |
2021-05-31T17:05:26 Z |
fvogel499 |
cmp (balkan11_cmp) |
C++14 |
|
10000 ms |
94300 KB |
/*
File created on 05/31/2021 at 18:32:22.
Link to problem: https://oj.uz/problem/view/balkan11_cmp
Description: https://usaco.guide/adv/interactive?lang=cpp#tip-1---dont-send-everything
Time complexity: irrelevant
Space complexity: irrelevant
Status: DEV
Copyright: Ⓒ 2021 Francois Vogel
*/
// #include <iostream>
#include <vector>
#include "cmp.h"
using namespace std;
vector<int> start = {0, 4, 20, 84, 340, 965, 2261};
// const int N = 10241;
// bool bits [N];
// void bit_set(int i) {
// bits[i] = true;
// }
// bool bit_get(int i) {
// return bits[i];
// }
void remember(int n) {
for (int i = 0; i < 6; i++) {
int cons = n>>(2*(5-i));
bit_set(cons+start[i]+1);
}
}
int compare(int n) {
int l = 0;
int r = 5;
while (true) {
int mid = (l+r)/2+1;
int cons = n>>(2*(5-mid));
bool res = bit_get(start[mid]+cons+1);
if (res) {
l = mid;
if (r == l) break;
}
else r = mid-1;
}
if (l == 5 and r == 5) return 0;
l++;
int cons = n>>(2*(5-l));
if (cons%4 == 0) return -1;
else if (cons%4 == 3) return 1;
else if (cons%4 == 1) {
bool res = bit_get(start[l]+cons-1+1);
if (res) return 1;
else return -1;
}
else if (cons%4 == 2) {
bool res = bit_get(start[l]+cons+1+1);
if (res) return -1;
else return 1;
}
}
// int main() {
// for (int i = 0; i < N; i++) bits[i] = false;
// int a, b;
// cin >> a >> b;
// remember(a);
// cout << compare(b);
// int d = 0;
// d++;
// }
Compilation message
cmp.cpp: In function 'int compare(int)':
cmp.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
63 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10089 ms |
94300 KB |
Time limit exceeded |