| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361394 | avahw | Coins (IOI17_coins) | C++20 | 3 ms | 592 KiB |
#include "coins.h"
#include <bits/stdc++.h>
using namespace std;
int get_val(vector<int>& b, int s){
int res = 0;
for(int i = 0; i <= s; i++){
res += b[i] * pow(2, i);
}
return res;
}
std::vector<int> coin_flips(std::vector<int> b, int c) {
vector<int> flips;
vector<vector<int>> lookup(3);
lookup[0] = {0, 0, 0, 7, 0, 7, 7, 7};
lookup[1] = {1, 1, 6, 1, 6, 1, 6, 6};
lookup[2] = {4, 3, 3, 3, 4, 4, 4, 3};
int curr = get_val(b, 2);
int message = lookup[c][curr];
for(int i = 2; i >= 0; i--){
if(message >= pow(2, i)){
if(b[i] != 1) flips.push_back(i);
message -= pow(2, i);
}
else{
if(b[i] != 0) flips.push_back(i);
}
}
if(flips.size() == 0) flips.push_back(63);
return flips;
}
int find_coin(std::vector<int> b) {
int message = get_val(b, 2);
vector<int> key(8);
key[0] = 0; key[7] = 0;
key[1] = 1; key[6] = 1;
key[3] = 2; key[4] = 2;
return key[message];
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
